respect document encoding

This commit is contained in:
Techatrix
2022-09-05 22:49:50 +02:00
parent 925cc3fee9
commit 7730c7715b
3 changed files with 64 additions and 78 deletions

View File

@@ -8,19 +8,9 @@ const log = std.log.scoped(.references);
const ast = @import("ast.zig");
fn tokenReference(handle: *DocumentStore.Handle, tok: Ast.TokenIndex, encoding: offsets.Encoding, context: anytype, comptime handler: anytype) !void {
const loc = offsets.tokenRelativeLocation(handle.tree, 0, handle.tree.tokens.items(.start)[tok], encoding) catch return;
try handler(context, types.Location{
.uri = handle.uri(),
.range = .{
.start = .{
.line = @intCast(i64, loc.line),
.character = @intCast(i64, loc.column),
},
.end = .{
.line = @intCast(i64, loc.line),
.character = @intCast(i64, loc.column + offsets.tokenLength(handle.tree, tok, encoding)),
},
},
.range = offsets.tokenToRange(handle.tree, tok,encoding) catch return,
});
}