From 8d8eb29d15d0b1383d7be8f1394fd4bb1b3a344d Mon Sep 17 00:00:00 2001 From: xdBronch <51252236+xdBronch@users.noreply.github.com> Date: Tue, 31 Dec 2024 17:42:38 -0500 Subject: [PATCH] escape identifiers when renaming (#2127) --- src/features/references.zig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/features/references.zig b/src/features/references.zig index af0b78568..d9108d418 100644 --- a/src/features/references.zig +++ b/src/features/references.zig @@ -497,13 +497,14 @@ pub fn referencesHandler(server: *Server, arena: std.mem.Allocator, request: Gen switch (request) { .rename => |rename| { + const escaped_rename = try std.fmt.allocPrint(arena, "{}", .{std.zig.fmtId(rename.newName)}); var changes = std.StringArrayHashMapUnmanaged(std.ArrayListUnmanaged(types.TextEdit)){}; for (locations.items) |loc| { const gop = try changes.getOrPutValue(arena, loc.uri, .{}); try gop.value_ptr.append(arena, .{ .range = loc.range, - .newText = rename.newName, + .newText = escaped_rename, }); }