Skip to content

Commit 9f26749

Browse files
Add decl literal completions for f(.<cursor>)
1 parent 86d539f commit 9f26749

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/features/completions.zig

+1
Original file line numberDiff line numberDiff line change
@@ -1086,6 +1086,7 @@ const EnumLiteralContext = struct {
10861086
return switch (likely) {
10871087
.enum_assignment,
10881088
.enum_return,
1089+
.enum_arg,
10891090
=> true,
10901091
else => false,
10911092
};

tests/lsp_features/completion.zig

+19
Original file line numberDiff line numberDiff line change
@@ -1638,6 +1638,25 @@ test "decl literal function" {
16381638
});
16391639
}
16401640

1641+
test "decl literal function call" {
1642+
try testCompletion(
1643+
\\const S = struct {
1644+
\\ field: u32,
1645+
\\
1646+
\\ const default: S = .{};
1647+
\\ fn init() S {}
1648+
\\};
1649+
\\fn foo(s: S) void {}
1650+
\\fn bar() void {
1651+
\\ foo(.<cursor>);
1652+
\\}
1653+
, &.{
1654+
.{ .label = "field", .kind = .Field, .detail = "u32" },
1655+
.{ .label = "default", .kind = .Struct },
1656+
.{ .label = "init", .kind = .Function, .detail = "fn () S" },
1657+
});
1658+
}
1659+
16411660
test "enum literal" {
16421661
try testCompletion(
16431662
\\const literal = .foo;

0 commit comments

Comments
 (0)