renderer: manual selection should take priority over search matches (#9714)

Previously it was impossible to select a search match. Well, it was
selecting but it wasn't showing that it was selected.
pull/9715/head
Mitchell Hashimoto 2025-11-26 10:30:42 -08:00 committed by GitHub
commit d213091452
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 15 additions and 10 deletions

View File

@ -2602,11 +2602,25 @@ pub fn Renderer(comptime GraphicsAPI: type) type {
search,
search_selected,
} = selected: {
// Order below matters for precedence.
// Selection should take the highest precedence.
const x_compare = if (wide == .spacer_tail)
x -| 1
else
x;
if (selection) |sel| {
if (x_compare >= sel[0] and
x_compare <= sel[1]) break :selected .selection;
}
// If we're highlighted, then we're selected. In the
// future we want to use a different style for this
// but this to get started.
for (highlights.items) |hl| {
if (x >= hl.range[0] and x <= hl.range[1]) {
if (x_compare >= hl.range[0] and
x_compare <= hl.range[1])
{
const tag: HighlightTag = @enumFromInt(hl.tag);
break :selected switch (tag) {
.search_match => .search,
@ -2615,15 +2629,6 @@ pub fn Renderer(comptime GraphicsAPI: type) type {
}
}
const sel = selection orelse break :selected .false;
const x_compare = if (wide == .spacer_tail)
x -| 1
else
x;
if (x_compare >= sel[0] and
x_compare <= sel[1]) break :selected .selection;
break :selected .false;
};