From 67a6d012919124811677bf42c6d885370d576891 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Thu, 15 Jan 2026 23:16:25 +0100 Subject: [PATCH] fix: always run highlight references if configured --- src/Project.zig | 2 +- src/tui/editor.zig | 36 ++++++++++++++---------------------- 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/src/Project.zig b/src/Project.zig index 002de9b..3712d6c 100644 --- a/src/Project.zig +++ b/src/Project.zig @@ -1142,7 +1142,7 @@ pub fn highlight_references(self: *Self, from: tp.pid_ref, file_path: []const u8 pub fn receive(self_: @This(), response: tp.message) !void { var highlights: []const u8 = undefined; if (try cbor.match(response.buf, .{ "child", tp.string, "result", tp.null_ })) { - return; + self_.from.send(.{ "HREF", self_.file_path, "done" }) catch {}; } else if (try cbor.match(response.buf, .{ "child", tp.string, "result", tp.extract_cbor(&highlights) })) { _ = try send_highlight_list(self_.from.ref(), highlights, self_.file_path); } diff --git a/src/tui/editor.zig b/src/tui/editor.zig index 7653db0..4e2861b 100644 --- a/src/tui/editor.zig +++ b/src/tui/editor.zig @@ -6243,7 +6243,6 @@ pub const Editor = struct { self.highlight_references_state = .adding; self.highlight_references_pending.clearRetainingCapacity(); } - self.match_type = .highlight_references; const root = self.buf_root() catch return; var match = match_; match.begin.row -|= 1; @@ -6254,11 +6253,13 @@ pub const Editor = struct { pub fn done_highlight_reference(self: *Self) void { self.cancel_all_matches(); + self.match_type = .highlight_references; for (self.highlight_references_pending.items) |match| (self.matches.addOne(self.allocator) catch return).* = match; - self.sort_matches(); + self.highlight_references_pending.clearRetainingCapacity(); self.highlight_references_state = .done; - self.need_render(); + self.sort_matches(); + tui.need_render(@src()); } pub fn add_diagnostic( @@ -6923,7 +6924,16 @@ pub const EditorWidget = struct { .hover => { try self.editor.hover(.{}); }, - .highlight_references => self.idle_highlight_references(), + .highlight_references => { + const primary = self.editor.get_primary(); + switch (self.editor.match_type) { + .find, .auto_find => {}, + .highlight_references, .none => { + if (self.editor.cursels.items.len == 1 and primary.selection == null) + self.editor.highlight_references(.{}) catch {}; + }, + } + }, }; return false; } else if (try m.match(.{ "whitespace_mode", tp.extract(&whitespace_mode) })) { @@ -6934,24 +6944,6 @@ pub const EditorWidget = struct { return true; } - fn idle_highlight_references(self: *Self) void { - const primary = self.editor.get_primary(); - switch (self.editor.match_type) { - .find, .auto_find => return, - .highlight_references => { - if (self.editor.match_at_cursor(primary.cursor)) |_| { - return; - } else { - self.editor.cancel_all_matches(); - tui.need_render(@src()); - } - }, - .none => {}, - } - if (self.editor.cursels.items.len == 1 and primary.selection == null) - self.editor.highlight_references(.{}) catch return; - } - fn update_hover_timer(self: *Self, event: enum { init, fired, cancel }) void { if (self.hover_timer) |*t| { if (event != .fired) t.cancel() catch {};