Skip to content

Commit

Permalink
fix builtin completions after variable decl type specifier
Browse files Browse the repository at this point in the history
fixes #1992
  • Loading branch information
Techatrix committed Aug 11, 2024
1 parent 15d0102 commit 1187c47
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
5 changes: 1 addition & 4 deletions src/analysis.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3528,10 +3528,7 @@ pub fn getPositionContext(
},
else => {},
},
.builtin => switch (curr_ctx.ctx) {
.empty, .pre_label => curr_ctx.ctx = .{ .builtin = tok.loc },
else => {},
},
.builtin => curr_ctx.ctx = .{ .builtin = tok.loc },
.period, .period_asterisk => switch (curr_ctx.ctx) {
.empty, .pre_label => curr_ctx.ctx = .{ .enum_literal = tok.loc },
.enum_literal => curr_ctx.ctx = .empty,
Expand Down
31 changes: 31 additions & 0 deletions tests/utility/position_context.zig
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,37 @@ test "builtin" {
"@intC",
);

try testContext(
\\var foo: <cursor>@
,
.empty,
null,
);
try testContext(
\\var foo: <cursor>@Thi();
,
.builtin,
"@Thi",
);
try testContext(
\\var foo: @<cursor>Thi();
,
.builtin,
"@Thi",
);
try testContext(
\\var foo: @Th<cursor>i();
,
.builtin,
"@Thi",
);
try testContext(
\\var foo: @Thi<cursor>();
,
.builtin,
"@Thi",
);

try testContext(
\\fn foo() void { <cursor>@setRuntime(false); };
,
Expand Down

0 comments on commit 1187c47

Please sign in to comment.