Closed xdBronch closed 1 month ago
Well spotted, xd
diff --git a/src/analysis.zig b/src/analysis.zig
index 904b6f0b..ef85ed9b 100644
--- a/src/analysis.zig
+++ b/src/analysis.zig
@@ -3482,6 +3482,8 @@ pub fn getPositionContext(
.enum_literal => curr_ctx.ctx = .{
.enum_literal = tokenLocAppend(curr_ctx.ctx.loc().?, tok),
},
+ // `if` or `while` condition w/out braces, e.g. `if (true) std.<cursor>`
+ .parens_expr => curr_ctx.ctx = .{ .var_access = tok.loc },
else => {},
},
.builtin => curr_ctx.ctx = .{ .builtin = tok.loc },
hm, this seems to mostly fix it but if i manually request completions (C-space
for me) i get nothing, only when i start to type something out does it work
hm, this seems to mostly fix it but if i manually request completions (
C-space
for me) i get nothing, only when i start to type something out does it work
Hmm
diff --git a/src/analysis.zig b/src/analysis.zig
index 904b6f0b..ef85ed9b 100644
--- a/src/analysis.zig
+++ b/src/analysis.zig
@@ -3482,6 +3482,8 @@ pub fn getPositionContext(
.enum_literal => curr_ctx.ctx = .{
.enum_literal = tokenLocAppend(curr_ctx.ctx.loc().?, tok),
},
+ // `if` or `while` condition w/out braces, e.g. `if (true) std.<cursor>`
+ .parens_expr => curr_ctx.ctx = .{ .var_access = tok.loc },
else => {},
},
.builtin => curr_ctx.ctx = .{ .builtin = tok.loc },
diff --git a/src/features/completions.zig b/src/features/completions.zig
index 804ec023..0b96ce1f 100644
--- a/src/features/completions.zig
+++ b/src/features/completions.zig
@@ -876,7 +876,7 @@ pub fn completionAtIndex(
switch (pos_context) {
.builtin => try completeBuiltin(&builder),
- .var_access, .empty => try completeGlobal(&builder),
+ .var_access, .empty, .parens_expr => try completeGlobal(&builder),
.field_access => |loc| try completeFieldAccess(&builder, loc),
.global_error_set => try globalSetCompletions(&builder, .error_set),
.enum_literal => |loc| try completeDot(&builder, loc),
yeah that does it thank you, were you planning on PRing this?
... were you planning on PRing this?
Not too eager, anyone is welcome to it.
Zig Version
0.14.0-dev.1349+6a21875dd
ZLS Version
0.14.0-dev.135+b481aae (with changes to make it compile on master)
Client / Code Editor / Extensions
No response
Steps to Reproduce and Observed Behavior
ask for completions and nothing happens, same with
while
.Expected Behavior
completions
Relevant log output
No response