diff options
| author | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-08-18 13:13:36 -0400 |
|---|---|---|
| committer | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-08-24 08:55:23 -0400 |
| commit | ebbb1f9aabd238a9ca2801bb8147aded8da4bb9f (patch) | |
| tree | 60fdd5c176152b40cced4279a542899f6468152d /src/server/completion.odin | |
| parent | debaa50a8d7c5a5dc35df68954a1bd702b6d094b (diff) | |
Handle pointers for selector expressions
Diffstat (limited to 'src/server/completion.odin')
| -rw-r--r-- | src/server/completion.odin | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/server/completion.odin b/src/server/completion.odin index 693c3d2..2dbb9cc 100644 --- a/src/server/completion.odin +++ b/src/server/completion.odin @@ -314,8 +314,7 @@ convert_completion_results :: proc( documentation = write_hover_content(ast_context, result.symbol), } - // TODO: support selector expressions as well - if s, ok := symbol.(Symbol); ok && completion_type == .Identifier { + if s, ok := symbol.(Symbol); ok && (completion_type == .Selector || completion_type == .Identifier) { diff := result.symbol.pointers - s.pointers suffix := "" prefix := "" @@ -325,7 +324,24 @@ convert_completion_results :: proc( if diff < 0 { prefix = "&" } - item.insertText = fmt.tprint(prefix, item.label, suffix, sep = "") + + if completion_type == .Identifier { + item.insertText = fmt.tprint(prefix, item.label, suffix, sep = "") + } else if completion_type == .Selector { + item.insertText = fmt.tprint(item.label, suffix, sep = "") + if prefix != "" { + if range, ok := get_range_from_selection_start_to_dot(position_context); ok { + prefix_edit := TextEdit { + range = {start = range.start, end = range.start}, + newText = "&", + } + + additionalTextEdits := make([]TextEdit, 1, context.temp_allocator) + additionalTextEdits[0] = prefix_edit + item.additionalTextEdits = additionalTextEdits + } + } + } } if common.config.enable_label_details { |