From d5166e2f6860c03dbc416aaca8b7b00e1836535c Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Tue, 3 Feb 2026 16:54:00 +0100 Subject: [PATCH] fix: override cursor focus rendering during dropdown completion --- src/tui/editor.zig | 7 ++++++- src/tui/mode/overlay/completion_dropdown.zig | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/tui/editor.zig b/src/tui/editor.zig index 75baec7..4c1a659 100644 --- a/src/tui/editor.zig +++ b/src/tui/editor.zig @@ -361,6 +361,7 @@ pub const Editor = struct { find_operation: ?enum { goto_next_match, goto_prev_match } = null, highlight_references_state: enum { adding, done } = .done, highlight_references_pending: Match.List = .empty, + cursor_focus_override: bool = false, prefix_buf: [8]u8 = undefined, prefix: []const u8 = &[_]u8{}, @@ -1307,7 +1308,7 @@ pub const Editor = struct { try self.render_cursor_primary(&self.get_primary().cursor, theme, cell_map, focused); } - fn render_cursor_primary(self: *Self, cursor: *const Cursor, theme: *const Widget.Theme, cell_map: CellMap, focused: bool) !void { + fn render_cursor_primary(self: *Self, cursor: *const Cursor, theme: *const Widget.Theme, cell_map: CellMap, focused_: bool) !void { const configured_shape = tui.get_cursor_shape(); const cursor_shape = if (tui.rdr().vx.caps.multi_cursor) configured_shape @@ -1321,6 +1322,8 @@ pub const Editor = struct { const screen_pos = self.screen_cursor(cursor); if (screen_pos) |pos| set_cell_map_cursor(cell_map, pos.row, pos.col); + const focused = focused_ or self.cursor_focus_override; + if (focused and self.enable_terminal_cursor) { if (screen_pos) |pos| { self.render_term_cursor(pos, cursor_shape); @@ -7145,6 +7148,7 @@ pub const EditorWidget = struct { } pub fn focus(self: *Self) void { + self.editor.cursor_focus_override = false; if (self.focused) return; self.commands.register() catch @panic("editor.commands.register"); self.focused = true; @@ -7153,6 +7157,7 @@ pub const EditorWidget = struct { } pub fn unfocus(self: *Self) void { + self.editor.cursor_focus_override = false; if (self.focused) self.commands.unregister(); self.focused = false; command.executeName("enter_mode_default", .{}) catch {}; diff --git a/src/tui/mode/overlay/completion_dropdown.zig b/src/tui/mode/overlay/completion_dropdown.zig index 0a87a19..ee2a1b6 100644 --- a/src/tui/mode/overlay/completion_dropdown.zig +++ b/src/tui/mode/overlay/completion_dropdown.zig @@ -46,6 +46,7 @@ pub fn init(self: *Type) error{ Stop, OutOfMemory }!void { try self.value.commands.init(self); self.value.editor = tui.get_active_editor() orelse return error.Stop; self.value.view = self.value.editor.view; + self.value.editor.cursor_focus_override = true; } pub fn load_entries(self: *Type) !usize {