fix: keep cursor position in Editor.add_cursor_all_matches

This commit is contained in:
CJ van den Berg 2025-12-05 11:50:17 +01:00
parent df3f373cde
commit 2cecc9b13b
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -3644,6 +3644,7 @@ pub const Editor = struct {
pub fn add_cursor_all_matches(self: *Self, _: Context) Result { pub fn add_cursor_all_matches(self: *Self, _: Context) Result {
if (self.matches.items.len == 0) return; if (self.matches.items.len == 0) return;
try self.send_editor_jump_source(); try self.send_editor_jump_source();
const primary_cursor = self.get_primary().cursor;
while (self.get_next_match(self.get_primary().cursor)) |match| { while (self.get_next_match(self.get_primary().cursor)) |match| {
if (self.get_primary().selection) |_| if (self.get_primary().selection) |_|
try self.push_cursor(); try self.push_cursor();
@ -3653,6 +3654,7 @@ pub const Editor = struct {
match.has_selection = true; match.has_selection = true;
primary.cursor.move_to(root, match.end.row, match.end.col, self.metrics) catch return; primary.cursor.move_to(root, match.end.row, match.end.col, self.metrics) catch return;
} }
self.set_primary_selection_from_cursor(primary_cursor) catch @panic("OOM add_cursor_all_matches");
self.clamp(); self.clamp();
try self.send_editor_jump_destination(); try self.send_editor_jump_destination();
} }