fix(lsp): rename_symbol: convert columns to byte offsets and back
This commit is contained in:
parent
61d9f583a8
commit
04b77b4d28
1 changed files with 15 additions and 2 deletions
|
@ -4224,13 +4224,26 @@ pub const Editor = struct {
|
|||
|
||||
pub fn rename_symbol(self: *Self, _: Context) Result {
|
||||
const file_path = self.file_path orelse return;
|
||||
const root = self.buf_root() catch return;
|
||||
const primary = self.get_primary();
|
||||
return project_manager.rename_symbol(file_path, primary.cursor.row, primary.cursor.col);
|
||||
const col = try root.get_line_width_to_pos(primary.cursor.row, primary.cursor.col, self.metrics);
|
||||
return project_manager.rename_symbol(file_path, primary.cursor.row, col);
|
||||
}
|
||||
pub const rename_symbol_meta = .{ .description = "Language: Rename symbol at cursor" };
|
||||
|
||||
pub fn add_rename_symbol_cursor(self: *Self, sel: Selection, first: bool) !void {
|
||||
pub fn add_rename_symbol_cursor(self: *Self, sel_: Selection, first: bool) !void {
|
||||
if (first) self.cancel_all_selections() else try self.push_cursor();
|
||||
const root = self.buf_root() catch return;
|
||||
const sel: Selection = .{
|
||||
.begin = .{
|
||||
.row = sel_.begin.row,
|
||||
.col = try root.pos_to_width(sel_.begin.row, sel_.begin.col, self.metrics),
|
||||
},
|
||||
.end = .{
|
||||
.row = sel_.end.row,
|
||||
.col = try root.pos_to_width(sel_.end.row, sel_.end.col, self.metrics),
|
||||
},
|
||||
};
|
||||
const primary = self.get_primary();
|
||||
primary.selection = sel;
|
||||
primary.cursor = sel.end;
|
||||
|
|
Loading…
Add table
Reference in a new issue