diff options
| author | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-08-19 10:10:07 -0400 |
|---|---|---|
| committer | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-08-19 10:10:07 -0400 |
| commit | 9970351043d75b9edea495780ca6fb68b67b346d (patch) | |
| tree | 98af9a5e138071679fbf379541e8fa1dccf47b99 /src | |
| parent | 9ffbad23c023a84f568d6079e1181442f5e70500 (diff) | |
Improvements to bitset completions with named bitsets and selector chains
Diffstat (limited to 'src')
| -rw-r--r-- | src/server/completion.odin | 31 | ||||
| -rw-r--r-- | src/server/methods.odin | 6 |
2 files changed, 14 insertions, 23 deletions
diff --git a/src/server/completion.odin b/src/server/completion.odin index 4abf8e2..01218cf 100644 --- a/src/server/completion.odin +++ b/src/server/completion.odin @@ -760,22 +760,9 @@ get_selector_completion :: proc( enumv, ok := unwrap_bitset(ast_context, selector) if !ok {break} - range, rok := get_range_from_selection_start_to_dot(position_context) + remove_edit, rok := create_remove_edit(position_context, true) if !rok {break} - range.end.character -= 1 - - variable, vok := position_context.selector.derived_expr.(^ast.Ident) - if !vok {break} - - remove_edit := TextEdit { - range = {start = range.start, end = range.end}, - newText = "", - } - - additionalTextEdits := make([]TextEdit, 1, context.temp_allocator) - additionalTextEdits[0] = remove_edit - for name in enumv.names { append( results, @@ -783,12 +770,12 @@ get_selector_completion :: proc( completion_item = CompletionItem { label = fmt.tprintf(".%s", name), kind = .EnumMember, - detail = fmt.tprintf("%s.%s", selector.name, name), - additionalTextEdits = additionalTextEdits, + detail = fmt.tprintf("%s.%s", receiver, name), + additionalTextEdits = remove_edit, }, }, ) - in_text := fmt.tprintf(".%s in %s", name, selector.name) + in_text := fmt.tprintf(".%s in %s", name, receiver) append( results, CompletionResult { @@ -796,12 +783,12 @@ get_selector_completion :: proc( label = fmt.tprintf(".%s in", name), kind = .EnumMember, detail = in_text, - insertText = in_text, - additionalTextEdits = additionalTextEdits, + insertText = in_text[1:], + additionalTextEdits = remove_edit, }, }, ) - not_in_text := fmt.tprintf(".%s not_in %s", name, selector.name) + not_in_text := fmt.tprintf(".%s not_in %s", name, receiver) append( results, CompletionResult { @@ -809,8 +796,8 @@ get_selector_completion :: proc( label = fmt.tprintf(".%s not_in", name), kind = .EnumMember, detail = not_in_text, - insertText = not_in_text, - additionalTextEdits = additionalTextEdits, + insertText = not_in_text[1:], + additionalTextEdits = remove_edit, }, }, ) diff --git a/src/server/methods.odin b/src/server/methods.odin index e60b84e..8b05840 100644 --- a/src/server/methods.odin +++ b/src/server/methods.odin @@ -19,7 +19,7 @@ import "src:common" @(private) -create_remove_edit :: proc(position_context: ^DocumentPositionContext) -> ([]TextEdit, bool) { +create_remove_edit :: proc(position_context: ^DocumentPositionContext, strip_leading_period := false) -> ([]TextEdit, bool) { range, ok := get_range_from_selection_start_to_dot(position_context) if !ok { @@ -31,6 +31,10 @@ create_remove_edit :: proc(position_context: ^DocumentPositionContext) -> ([]Tex end = range.end, } + if strip_leading_period { + remove_range.end.character -= 1 + } + remove_edit := TextEdit { range = remove_range, newText = "", |