From 098d9253582b263723701bdafca2574738490d79 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Tue, 9 Dec 2025 19:18:26 +0100 Subject: [PATCH] refactor: add editor.add_match_from_selection function --- src/tui/editor.zig | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/tui/editor.zig b/src/tui/editor.zig index 6a7a738..6aeaf02 100644 --- a/src/tui/editor.zig +++ b/src/tui/editor.zig @@ -5460,6 +5460,13 @@ pub const Editor = struct { (self.matches.addOne(self.allocator) catch return).* = match; } + fn add_match_from_selection(self: *Self, sel: Selection) void { + var match: Match = Match.from_selection(sel); + if (match.end.eql(self.get_primary().cursor)) + match.has_selection = true; + (self.matches.addOne(self.allocator) catch return).* = match; + } + fn find_selection_match(self: *const Self, sel: Selection) ?*Match { for (self.matches.items) |*match_| if (match_.*) |*match| { if (match.to_selection().eql(sel))