diff --git a/src/analysis.zig b/src/analysis.zig index 90dc34d..80c40a5 100644 --- a/src/analysis.zig +++ b/src/analysis.zig @@ -555,6 +555,7 @@ pub fn getFieldAccessTypeNode( store: *DocumentStore, arena: *std.heap.ArenaAllocator, handle: *DocumentStore.Handle, + source_index: usize, tokenizer: *std.zig.Tokenizer, ) !?NodeWithHandle { var current_node = NodeWithHandle{ @@ -567,7 +568,7 @@ pub fn getFieldAccessTypeNode( switch (tok.id) { .Eof => return try resolveFieldAccessLhsType(store, arena, current_node), .Identifier => { - if (try lookupSymbolGlobal(store, current_node.handle, tokenizer.buffer[tok.loc.start..tok.loc.end], tok.loc.start)) |child| { + if (try lookupSymbolGlobal(store, current_node.handle, tokenizer.buffer[tok.loc.start..tok.loc.end], source_index)) |child| { current_node = (try child.resolveType(store, arena)) orelse return null; } else return null; }, diff --git a/src/main.zig b/src/main.zig index 752c9f6..c2cc6e4 100644 --- a/src/main.zig +++ b/src/main.zig @@ -525,7 +525,7 @@ fn getSymbolFieldAccess( const line = try handle.document.getLine(@intCast(usize, position.line)); var tokenizer = std.zig.Tokenizer.init(line[range.start..range.end]); - if (try analysis.getFieldAccessTypeNode(&document_store, arena, handle, &tokenizer)) |container_handle| { + if (try analysis.getFieldAccessTypeNode(&document_store, arena, handle, pos_index, &tokenizer)) |container_handle| { return try analysis.lookupSymbolContainer(&document_store, container_handle, name, true); } return null; @@ -670,7 +670,8 @@ fn completeFieldAccess(id: types.RequestId, handle: *DocumentStore.Handle, posit const line = try handle.document.getLine(@intCast(usize, position.line)); var tokenizer = std.zig.Tokenizer.init(line[range.start..range.end]); - if (try analysis.getFieldAccessTypeNode(&document_store, &arena, handle, &tokenizer)) |node| { + const pos_index = try handle.document.positionToIndex(position); + if (try analysis.getFieldAccessTypeNode(&document_store, &arena, handle, pos_index, &tokenizer)) |node| { try nodeToCompletion(&arena, &completions, node, handle, config); }