Compare commits
3 commits
58622a5531
...
141f5595ff
| Author | SHA1 | Date | |
|---|---|---|---|
| 141f5595ff | |||
| 2cecc9b13b | |||
| df3f373cde |
2 changed files with 23 additions and 3 deletions
|
|
@ -3644,6 +3644,7 @@ 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();
|
||||
|
|
@ -3653,6 +3654,7 @@ 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();
|
||||
}
|
||||
|
|
@ -5910,6 +5912,25 @@ 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;
|
||||
|
|
|
|||
|
|
@ -1105,9 +1105,7 @@ const cmds = struct {
|
|||
|
||||
pub fn rename_symbol_item(self: *Self, ctx: Ctx) Result {
|
||||
const editor = self.get_active_editor() orelse return;
|
||||
// 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.
|
||||
const primary_cursor = editor.get_primary().cursor;
|
||||
var iter = ctx.args.buf;
|
||||
var len = try cbor.decodeArrayHeader(&iter);
|
||||
var first = true;
|
||||
|
|
@ -1144,6 +1142,7 @@ 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 } };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue