diff options
| author | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-08-11 15:20:10 -0400 |
|---|---|---|
| committer | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-08-11 15:20:13 -0400 |
| commit | a631a5d232927c658968c3d6040c46b11f2d412b (patch) | |
| tree | 3db51a2123b7b088e0cfeb447ec36188997714b5 | |
| parent | 3d1b2d482f9c1e0ddb0c3acf2890724f36b51643 (diff) | |
Resolve implicit completions with variadic arguments
| -rw-r--r-- | src/server/symbol.odin | 4 | ||||
| -rw-r--r-- | tests/completions_test.odin | 20 |
2 files changed, 24 insertions, 0 deletions
diff --git a/src/server/symbol.odin b/src/server/symbol.odin index 77c4cb0..cf2c4ed 100644 --- a/src/server/symbol.odin +++ b/src/server/symbol.odin @@ -557,6 +557,10 @@ get_proc_arg_count :: proc(v: SymbolProcedureValue) -> int { get_proc_arg_type_from_index :: proc(value: SymbolProcedureValue, parameter_index: int) -> (^ast.Field, bool) { index := 0 for arg in value.arg_types { + // We're in a variadic arg, so return true + if _, ok := arg.type.derived.(^ast.Ellipsis); ok { + return arg, true + } for name in arg.names { if index == parameter_index { return arg, true diff --git a/tests/completions_test.odin b/tests/completions_test.odin index 58e5c11..6a3996e 100644 --- a/tests/completions_test.odin +++ b/tests/completions_test.odin @@ -4287,3 +4287,23 @@ ast_completion_proc_field_names :: proc(t: ^testing.T) { } test.expect_completion_docs( t, &source, "", {"test.bar: string"}) } + +@(test) +ast_completion_enum_variadiac_args :: proc(t: ^testing.T) { + source := test.Source { + main = `package test + Foo :: enum { + A, + B, + C, + } + + foo :: proc(foos: ..Foo) {} + + main :: proc() { + foo(.A, .{*}) + } + `, + } + test.expect_completion_docs( t, &source, "", {"A", "B", "C"}) +} |