refactor: add editor.add_match_from_selection function

This commit is contained in:
CJ van den Berg 2025-12-09 19:18:26 +01:00
parent 8152de3df9
commit 098d925358
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -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))