feat(lsp): rename_symbol: add support for LSPs that do send document updates for renames

This commit is contained in:
CJ van den Berg 2025-01-18 20:34:14 +01:00
parent 04b77b4d28
commit 4277f0f57b
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
2 changed files with 76 additions and 5 deletions

View file

@ -562,8 +562,7 @@ const cmds = struct {
var iter = ctx.args.buf;
var len = try cbor.decodeArrayHeader(&iter);
var first = true;
while (len != 0) {
len -= 1;
while (len != 0) : (len -= 1) {
if (try cbor.decodeArrayHeader(&iter) != 7) return error.InvalidRenameSymbolItemArgument;
var file_path: []const u8 = undefined;
if (!try cbor.matchString(&iter, &file_path)) return error.MissingArgument;
@ -579,7 +578,9 @@ const cmds = struct {
file_path = project_manager.normalize_file_path(file_path);
if (std.mem.eql(u8, file_path, editor.file_path orelse "")) {
try editor.add_rename_symbol_cursor(sel, first);
if (len == 1 and sel.begin.row == 0 and sel.begin.col == 0 and sel.end.row > 0) //probably a full file edit
return editor.add_cursors_from_content_diff(new_text);
try editor.add_cursor_from_selection(sel, if (first) .cancel else .push);
first = false;
} else {
try self.add_find_in_files_result(