From e9a3c436d6fc23a1622e59394aff1c34762b2482 Mon Sep 17 00:00:00 2001 From: Brad Lewis <22850972+BradLewis@users.noreply.github.com> Date: Sat, 13 Sep 2025 22:35:24 -0400 Subject: Revert "Merge pull request #1011 from BradLewis/fix/completions-select-in-selector-call" This reverts commit 69c2024f8a65244d46941fbbf6459fed01348dee, reversing changes made to a581608407b82b4816b7fbbe29da97c55c53c33e. --- src/server/completion.odin | 9 ++------- src/server/position_context.odin | 2 +- tests/completions_test.odin | 30 +----------------------------- 3 files changed, 4 insertions(+), 37 deletions(-) diff --git a/src/server/completion.odin b/src/server/completion.odin index 5eb8e64..7e789f0 100644 --- a/src/server/completion.odin +++ b/src/server/completion.odin @@ -96,9 +96,7 @@ get_completion_list :: proc( } if position_context.selector != nil { - if _, ok := position_context.selector.derived.(^ast.Ident); ok { - completion_type = .Selector - } else if position_context.selector_expr != nil { + if position_context.selector_expr != nil { if selector_call, ok := position_context.selector_expr.derived.(^ast.Selector_Call_Expr); ok { if !position_in_node(selector_call.call, position_context.position) { completion_type = .Selector @@ -1403,10 +1401,7 @@ get_implicit_completion :: proc( } if len(position_context.assign.lhs) > rhs_index { - if enum_value, unwrapped_super_enum, ok := unwrap_enum( - ast_context, - position_context.assign.lhs[rhs_index], - ); ok { + if enum_value, unwrapped_super_enum, ok := unwrap_enum(ast_context, position_context.assign.lhs[rhs_index]); ok { for name in enum_value.names { item := CompletionItem { label = name, diff --git a/src/server/position_context.odin b/src/server/position_context.odin index 46efce2..0417df8 100644 --- a/src/server/position_context.odin +++ b/src/server/position_context.odin @@ -138,7 +138,7 @@ get_document_position_context :: proc( position_context.parent_binary = nil } - if hint == .Completion { + if hint == .Completion && position_context.selector == nil && position_context.field == nil { fallback_position_context_completion(document, position, &position_context) } diff --git a/tests/completions_test.odin b/tests/completions_test.odin index a9b24ce..303fd64 100644 --- a/tests/completions_test.odin +++ b/tests/completions_test.odin @@ -4720,37 +4720,9 @@ ast_completion_selector_within_selector_call_expr :: proc(t: ^testing.T) { bar = print, } - foo->bar(data.{*}) + foo->bar(data.x{*}) } `, } test.expect_completion_docs(t, &source, "", {"Data.x: int", "Data.y: int"}) } - -@(test) -ast_completion_ident_within_selector_call_expr :: proc(t: ^testing.T) { - source := test.Source { - main = `package test - - Data :: struct { - x, y: int, - } - - IFoo :: struct { - bar: proc(self: IFoo, x: int), - } - - print :: proc(self: IFoo, x: int) {} - - main :: proc() { - data := Data{} - foo := IFoo { - bar = print, - } - - foo->bar(d{*}) - } - `, - } - test.expect_completion_docs(t, &source, "", {"test.data: test.Data"}) -} -- cgit v1.2.3 From 963411cf80140f1231f3b17d76c68d09655ebef4 Mon Sep 17 00:00:00 2001 From: Brad Lewis <22850972+BradLewis@users.noreply.github.com> Date: Sat, 13 Sep 2025 22:35:37 -0400 Subject: Revert "Merge pull request #1010 from BradLewis/fix/completions-selector-in-selector-call" This reverts commit a581608407b82b4816b7fbbe29da97c55c53c33e, reversing changes made to a697921c2556eb14f10fb54117f83dca4fffd027. --- src/server/completion.odin | 2 -- src/server/position_context.odin | 5 +---- tests/completions_test.odin | 28 ---------------------------- 3 files changed, 1 insertion(+), 34 deletions(-) diff --git a/src/server/completion.odin b/src/server/completion.odin index 7e789f0..aceff60 100644 --- a/src/server/completion.odin +++ b/src/server/completion.odin @@ -101,8 +101,6 @@ get_completion_list :: proc( if !position_in_node(selector_call.call, position_context.position) { completion_type = .Selector } - } else if selector, ok := position_context.selector_expr.derived.(^ast.Selector_Expr); ok { - completion_type = .Selector } } else if _, ok := position_context.selector.derived.(^ast.Implicit_Selector_Expr); !ok { // variadic args seem to work by setting it as an implicit selector expr, in that case diff --git a/src/server/position_context.odin b/src/server/position_context.odin index 0417df8..d5e7d33 100644 --- a/src/server/position_context.odin +++ b/src/server/position_context.odin @@ -649,10 +649,7 @@ get_document_position_node :: proc(node: ^ast.Node, position_context: ^DocumentP } } case ^Selector_Expr: - if position_context.hint == .Definition || - position_context.hint == .Hover || - position_context.hint == .SignatureHelp || - position_context.hint == .Completion { + if position_context.hint == .Definition || position_context.hint == .Hover && n.field != nil { position_context.selector = n.expr position_context.field = n.field position_context.selector_expr = node diff --git a/tests/completions_test.odin b/tests/completions_test.odin index 303fd64..d3a2eb7 100644 --- a/tests/completions_test.odin +++ b/tests/completions_test.odin @@ -4698,31 +4698,3 @@ ast_completion_struct_field_value :: proc(t: ^testing.T) { } test.expect_completion_docs(t, &source, "", {"test.Foo: struct {}"}) } - -@(test) -ast_completion_selector_within_selector_call_expr :: proc(t: ^testing.T) { - source := test.Source { - main = `package test - - Data :: struct { - x, y: int, - } - - IFoo :: struct { - bar: proc(self: IFoo, x: int), - } - - print :: proc(self: IFoo, x: int) {} - - main :: proc() { - data := Data{} - foo := IFoo { - bar = print, - } - - foo->bar(data.x{*}) - } - `, - } - test.expect_completion_docs(t, &source, "", {"Data.x: int", "Data.y: int"}) -} -- cgit v1.2.3