diff --git a/src/tui/editor.zig b/src/tui/editor.zig index 8b7bbec..18d6a0c 100644 --- a/src/tui/editor.zig +++ b/src/tui/editor.zig @@ -3644,7 +3644,6 @@ pub const Editor = struct { pub fn add_cursor_all_matches(self: *Self, _: Context) Result { if (self.matches.items.len == 0) return; try self.send_editor_jump_source(); - const primary_cursor = self.get_primary().cursor; while (self.get_next_match(self.get_primary().cursor)) |match| { if (self.get_primary().selection) |_| try self.push_cursor(); @@ -3654,7 +3653,6 @@ pub const Editor = struct { match.has_selection = true; 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(); try self.send_editor_jump_destination(); } @@ -5912,25 +5910,6 @@ pub const Editor = struct { } } - pub fn set_primary_selection_from_cursor(self: *Self, cursor: Cursor) error{OutOfMemory}!void { - const idx = for (self.cursels.items, 0..) |*cursel_, idx| { - if (cursel_.*) |*cursel| { - if (cursel.selection) |sel| if (cursor.within(sel)) break idx; - } - } else return; - - const cursels = try self.cursels.toOwnedSlice(self.allocator); - defer self.allocator.free(cursels); - - for (cursels[idx + 1 ..]) |*cursel_| if (cursel_.*) |*cursel| { - (try self.cursels.addOne(self.allocator)).* = cursel.*; - }; - - for (cursels[0 .. idx + 1]) |*cursel_| if (cursel_.*) |*cursel| { - (try self.cursels.addOne(self.allocator)).* = cursel.*; - }; - } - fn count_lines(content: []const u8) struct { usize, usize } { var pos = content; var offset = content.len; diff --git a/src/tui/mainview.zig b/src/tui/mainview.zig index 0147369..a822b63 100644 --- a/src/tui/mainview.zig +++ b/src/tui/mainview.zig @@ -1105,7 +1105,9 @@ const cmds = struct { pub fn rename_symbol_item(self: *Self, ctx: Ctx) Result { const editor = self.get_active_editor() orelse return; - const primary_cursor = editor.get_primary().cursor; + // because the incoming message is an array of Renames, we manuallly + // parse instead of using ctx.args.match() which doesn't seem to return + // the parsed length needed to correctly advance iter. var iter = ctx.args.buf; var len = try cbor.decodeArrayHeader(&iter); var first = true; @@ -1142,7 +1144,6 @@ const cmds = struct { ); } } - try editor.set_primary_selection_from_cursor(primary_cursor); } pub const rename_symbol_item_meta: Meta = .{ .arguments = &.{.array} }; pub const rename_symbol_item_elem_meta: Meta = .{ .arguments = &.{ .string, .integer, .integer, .integer, .integer, .string } };