diff options
| -rw-r--r-- | src/server/completion.odin | 5 | ||||
| -rw-r--r-- | tests/completions_test.odin | 18 |
2 files changed, 22 insertions, 1 deletions
diff --git a/src/server/completion.odin b/src/server/completion.odin index 8a0f371..0324b23 100644 --- a/src/server/completion.odin +++ b/src/server/completion.odin @@ -785,7 +785,10 @@ get_selector_completion :: proc( selector.type != .Field && selector.type != .Package && selector.type != .Enum && - selector.type != .Function { + selector.type != .Function && + (selector.type == .Struct && .Variable not_in selector.flags) { + // We don't want completions for struct types, but we do want completions for constant variables. + // See tests `ast_global_non_mutable_completion` vs `ast_completion_global_selector_from_local_scope` return is_incomplete } diff --git a/tests/completions_test.odin b/tests/completions_test.odin index 72dcb86..5ab4181 100644 --- a/tests/completions_test.odin +++ b/tests/completions_test.odin @@ -5130,3 +5130,21 @@ ast_completion_implicit_selector_binary_expr :: proc(t: ^testing.T) { } test.expect_completion_docs(t, &source, "", {"A", "B"}) } + +@(test) +ast_completion_global_selector_from_local_scope :: proc(t: ^testing.T) { + source := test.Source { + main = `package test + Foo :: struct { + foo: int, + } + + FOO :: Foo{} + + main :: proc() { + FOO.{*} + } + `, + } + test.expect_completion_docs(t, &source, "", {"Foo.foo: int"}) +} |