diff options
| -rw-r--r-- | src/server/completion.odin | 7 | ||||
| -rw-r--r-- | tests/completions_test.odin | 17 |
2 files changed, 22 insertions, 2 deletions
diff --git a/src/server/completion.odin b/src/server/completion.odin index edf6578..5d39109 100644 --- a/src/server/completion.odin +++ b/src/server/completion.odin @@ -154,7 +154,7 @@ get_completion_list :: proc( // TODO: as these are mutally exclusive, should probably just make them return a slice? switch completion_type { case .Comp_Lit: - is_incomplete = get_comp_lit_completion(&ast_context, &position_context, &results) + is_incomplete = get_comp_lit_completion(&ast_context, &position_context, &results, config) case .Identifier: is_incomplete = get_identifier_completion(&ast_context, &position_context, &results, config) case .Implicit: @@ -646,6 +646,7 @@ get_comp_lit_completion :: proc( ast_context: ^AstContext, position_context: ^DocumentPositionContext, results: ^[dynamic]CompletionResult, + config: ^common.Config, ) -> bool { if symbol, ok := resolve_comp_literal(ast_context, position_context); ok { #partial switch v in symbol.value { @@ -666,6 +667,7 @@ get_comp_lit_completion :: proc( append(results, CompletionResult{symbol = resolved}) } } + return false case SymbolBitFieldValue: for name, i in v.names { if name == "_" { @@ -683,6 +685,7 @@ get_comp_lit_completion :: proc( append(results, CompletionResult{symbol = resolved}) } } + return false case SymbolFixedArrayValue: if symbol, ok := resolve_type_expression(ast_context, v.len); ok { if v, ok := symbol.value.(SymbolEnumValue); ok { @@ -694,9 +697,11 @@ get_comp_lit_completion :: proc( construct_enum_field_symbol(&symbol, v, i) append(results, CompletionResult{symbol = symbol}) } + return false } } } + return get_identifier_completion(ast_context, position_context, results, config) } return false diff --git a/tests/completions_test.odin b/tests/completions_test.odin index cb05518..74de905 100644 --- a/tests/completions_test.odin +++ b/tests/completions_test.odin @@ -1,6 +1,5 @@ package tests -import "core:fmt" import "core:strings" import "core:testing" @@ -4787,3 +4786,19 @@ ast_completion_overload_proc_returning_proc_complete_comp_lit_arg_direct :: proc } test.expect_completion_docs(t, &source, "", {"Foo.bar: int", "Foo.bazz: string"}) } + +@(test) +ast_completion_array_comp_lit :: proc(t: ^testing.T) { + source := test.Source { + main = `package test + main :: proc() { + foo1 := 1 + foo2 := 2 + + foos: [2]int + foos = {{*}} + } + `, + } + test.expect_completion_docs(t, &source, "", {"test.foo1: int", "test.foo2: int"}) +} |