diff --git a/src/analysis.zig b/src/analysis.zig index 904b6f0b6..ae35af75b 100644 --- a/src/analysis.zig +++ b/src/analysis.zig @@ -3473,7 +3473,11 @@ pub fn getPositionContext( curr_ctx.ctx = .{ .string_literal = tok.loc }; }, .identifier => switch (curr_ctx.ctx) { - .empty, .pre_label, .var_access => curr_ctx.ctx = .{ .var_access = tok.loc }, + .empty, + .pre_label, + .var_access, + .parens_expr, + => curr_ctx.ctx = .{ .var_access = tok.loc }, .label => |filled| if (!filled) { curr_ctx.ctx = .{ .label = true }; } else { @@ -3561,6 +3565,7 @@ pub fn getPositionContext( return state.ctx; } }, + .parens_expr => |loc| return .{ .var_access = loc }, else => return state.ctx, } } diff --git a/tests/lsp_features/completion.zig b/tests/lsp_features/completion.zig index 1e0464d9f..7c66e954a 100644 --- a/tests/lsp_features/completion.zig +++ b/tests/lsp_features/completion.zig @@ -817,6 +817,14 @@ test "if/for/while/catch scopes" { , &.{ .{ .label = "T", .kind = .Constant, .detail = "u32" }, }); + try testCompletion( + \\const S = struct { pub const T = u32; }; + \\test { + \\ if (true) S. + \\} + , &.{ + .{ .label = "T", .kind = .Constant, .detail = "u32" }, + }); try testCompletion( \\const S = struct { pub const T = u32; }; \\test {