lsp-rename: minor cosmetic cleanups
This commit is contained in:
parent
860c36266c
commit
bfdeffc70f
3 changed files with 14 additions and 10 deletions
|
@ -807,9 +807,9 @@ pub fn rename_symbol(self: *Self, from: tp.pid_ref, file_path: []const u8, row:
|
|||
if (try cbor.match(response.buf, .{ tp.any, tp.any, tp.any, tp.extract_cbor(&result) })) {
|
||||
try self.decode_rename_symbol_map(result, &renames);
|
||||
// write the renames message manually since there doesn't appear to be an array helper
|
||||
var m = std.ArrayList(u8).init(self.allocator);
|
||||
const w = m.writer();
|
||||
defer m.deinit();
|
||||
var msg_buf = std.ArrayList(u8).init(self.allocator);
|
||||
defer msg_buf.deinit();
|
||||
const w = msg_buf.writer();
|
||||
try cbor.writeArrayHeader(w, 3);
|
||||
try cbor.writeValue(w, "cmd");
|
||||
try cbor.writeValue(w, "rename_symbol_item");
|
||||
|
@ -824,7 +824,7 @@ pub fn rename_symbol(self: *Self, from: tp.pid_ref, file_path: []const u8, row:
|
|||
rename.new_text,
|
||||
});
|
||||
}
|
||||
from.send_raw(.{ .buf = m.items }) catch return error.ClientFailed;
|
||||
from.send_raw(.{ .buf = msg_buf.items }) catch return error.ClientFailed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ pub const ArgumentType = enum {
|
|||
integer,
|
||||
float,
|
||||
object,
|
||||
array,
|
||||
};
|
||||
|
||||
pub fn Closure(comptime T: type) type {
|
||||
|
|
|
@ -562,18 +562,18 @@ const cmds = struct {
|
|||
var len = try cbor.decodeArrayHeader(&iter);
|
||||
var mroot: ?@import("Buffer").Root = null;
|
||||
while (len != 0) {
|
||||
var file_uri: []const u8 = undefined;
|
||||
var sel: ed.Selection = .{};
|
||||
var new_text: []const u8 = undefined;
|
||||
len -= 1;
|
||||
std.debug.assert(try cbor.decodeArrayHeader(&iter) == 6);
|
||||
var file_uri: []const u8 = undefined;
|
||||
if (!try cbor.matchString(&iter, &file_uri)) return error.MissingArgument;
|
||||
var sel: ed.Selection = .{};
|
||||
if (!try cbor.matchInt(usize, &iter, &sel.begin.row)) return error.MissingArgument;
|
||||
if (!try cbor.matchInt(usize, &iter, &sel.begin.col)) return error.MissingArgument;
|
||||
if (!try cbor.matchInt(usize, &iter, &sel.end.row)) return error.MissingArgument;
|
||||
if (!try cbor.matchInt(usize, &iter, &sel.end.col)) return error.MissingArgument;
|
||||
var new_text: []const u8 = undefined;
|
||||
if (!try cbor.matchString(&iter, &new_text)) return error.MissingArgument;
|
||||
file_uri = project_manager.normalize_file_path(file_uri);
|
||||
|
||||
if (self.get_active_editor()) |editor| {
|
||||
// TODO match file_uri correctly. endsWith() isn't correct because 'path' is a
|
||||
// short, relative path while 'file_uri' is an absolute path starting with 'file://'
|
||||
|
@ -581,12 +581,15 @@ const cmds = struct {
|
|||
if (match) {
|
||||
try editor.rename_symbol_item(sel, new_text, &mroot, len == 0);
|
||||
} else {
|
||||
log.logger("LSP").print("TODO perform renames in other files\n", .{});
|
||||
const logger = log.logger("LSP");
|
||||
defer logger.deinit();
|
||||
logger.print("TODO perform renames in other files\n", .{});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
pub const rename_symbol_item_meta = .{ .arguments = &.{ .string, .integer, .integer, .integer, .integer, .string } };
|
||||
pub const rename_symbol_item_meta = .{ .arguments = &.{.array} };
|
||||
pub const rename_symbol_item_elem_meta = .{ .arguments = &.{ .string, .integer, .integer, .integer, .integer, .string } };
|
||||
|
||||
pub fn clear_diagnostics(self: *Self, ctx: Ctx) Result {
|
||||
var file_path: []const u8 = undefined;
|
||||
|
|
Loading…
Add table
Reference in a new issue