From 834b61b16fd30f2497cded46d1dc60a7f18ce601 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Mon, 10 Nov 2025 12:28:22 +0100 Subject: [PATCH] fix: scan_next_match should find the match at the cursor if it is not selected --- src/tui/editor.zig | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/tui/editor.zig b/src/tui/editor.zig index 354e860..f83aba3 100644 --- a/src/tui/editor.zig +++ b/src/tui/editor.zig @@ -5366,9 +5366,12 @@ pub const Editor = struct { const row = cursor.row; const col = cursor.col; const multi_cursor = self.cursels.items.len > 1; - for (self.matches.items) |*match_| if (match_.*) |*match| - if ((!multi_cursor or !match.has_selection) and (row < match.begin.row or (row == match.begin.row and col < match.begin.col))) - return match; + for (self.matches.items) |*match_| if (match_.*) |*match| { + if (match.has_selection) continue; + if (cursor.within(match.to_selection())) return match; + if (multi_cursor) continue; + if (row < match.begin.row or (row == match.begin.row and col < match.begin.col)) return match; + }; return null; }