fix: select previous symbol if there is no symbol at the cursor

This commit is contained in:
CJ van den Berg 2025-11-18 20:03:36 +01:00
parent ae6df9dba8
commit f9bbb55814
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -191,10 +191,13 @@ fn get_values(item_cbor: []const u8) struct { []const u8, []const u8, u8, ed.Sel
fn find_closest(palette: *Type) ?usize {
const editor = tui.get_active_editor() orelse return null;
const cursor = editor.get_primary().cursor;
var previous: usize = 0;
for (palette.entries.items, 0..) |entry, idx| {
_, _, _, const sel = get_values(entry.cbor);
if (cursor.within(sel))
return idx + 1;
if (cursor.row < sel.begin.row) return previous + 1;
previous = idx;
}
return null;
}