diff options
| author | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-09-28 14:52:38 -0400 |
|---|---|---|
| committer | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-09-28 15:14:38 -0400 |
| commit | bcd4dae92538d940404fb3716333a0f6e0d111e2 (patch) | |
| tree | 212bb77f0d9752e6f5be9429805711727d210a12 /src/server | |
| parent | 4a2a71e12d61be1cd8ca486d96de8dd47dd49df2 (diff) | |
Fix ordering of completions with same score
Diffstat (limited to 'src/server')
| -rw-r--r-- | src/server/completion.odin | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/server/completion.odin b/src/server/completion.odin index 75bec86..febf76f 100644 --- a/src/server/completion.odin +++ b/src/server/completion.odin @@ -241,14 +241,14 @@ convert_completion_results :: proc( config: ^common.Config, ) -> []CompletionItem { for &result in results { - score_completion_item(&result) + score_completion_item(&result, ast_context.current_package) } slice.sort_by(results, proc(i, j: CompletionResult) -> bool { if j.score != i.score { return j.score < i.score } - return j.symbol.name < i.symbol.name + return j.symbol.name > i.symbol.name }) top_results := results @@ -387,7 +387,7 @@ convert_completion_results :: proc( return items[:] } -score_completion_item :: proc(item: ^CompletionResult) { +score_completion_item :: proc(item: ^CompletionResult, curr_pkg: string) { if _, ok := item.completion_item.?; ok { return } @@ -403,6 +403,10 @@ score_completion_item :: proc(item: ^CompletionResult) { if item.symbol.type == .Field { item.score += 2 } + + if item.symbol.pkg == curr_pkg { + item.score += 1 + } } @(private = "file") |