Skip to content

Commit e4576de

Browse files
committed
preselect do completion to make it more preferred than defoverride
Fixes #302
1 parent 5fe75ba commit e4576de

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

apps/language_server/lib/language_server/providers/completion.ex

+12-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ defmodule ElixirLS.LanguageServer.Providers.Completion do
2020
# Lower priority is shown higher in the result list
2121
:priority,
2222
:tags,
23-
:command
23+
:command,
24+
{:preselect, false}
2425
]
2526

2627
@func_snippets %{
@@ -163,7 +164,9 @@ defmodule ElixirLS.LanguageServer.Providers.Completion do
163164
detail: "keyword",
164165
insert_text: "do\n $0\nend",
165166
tags: [],
166-
priority: 0
167+
priority: 0,
168+
# force selection over other longer not exact completions
169+
preselect: true
167170
}
168171

169172
[item | completion_items]
@@ -978,9 +981,15 @@ defmodule ElixirLS.LanguageServer.Providers.Completion do
978981
insert_text_format(:snippet)
979982
else
980983
insert_text_format(:plain_text)
981-
end
984+
end,
982985
}
983986

987+
json = if item.preselect do
988+
Map.put(json, "preselect", true)
989+
else
990+
json
991+
end
992+
984993
# deprecated as of Language Server Protocol Specification - 3.15
985994
json =
986995
if Keyword.get(options, :deprecated_supported, false) do

0 commit comments

Comments
 (0)