Skip to content

Commit

Permalink
preselect do completion to make it more preferred than defoverride
Browse files Browse the repository at this point in the history
Fixes #302
  • Loading branch information
lukaszsamson committed Jul 5, 2022
1 parent 5fe75ba commit e4576de
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions apps/language_server/lib/language_server/providers/completion.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ defmodule ElixirLS.LanguageServer.Providers.Completion do
# Lower priority is shown higher in the result list
:priority,
:tags,
:command
:command,
{:preselect, false}
]

@func_snippets %{
Expand Down Expand Up @@ -163,7 +164,9 @@ defmodule ElixirLS.LanguageServer.Providers.Completion do
detail: "keyword",
insert_text: "do\n $0\nend",
tags: [],
priority: 0
priority: 0,
# force selection over other longer not exact completions
preselect: true
}

[item | completion_items]
Expand Down Expand Up @@ -978,9 +981,15 @@ defmodule ElixirLS.LanguageServer.Providers.Completion do
insert_text_format(:snippet)
else
insert_text_format(:plain_text)
end
end,
}

json = if item.preselect do
Map.put(json, "preselect", true)
else
json
end

# deprecated as of Language Server Protocol Specification - 3.15
json =
if Keyword.get(options, :deprecated_supported, false) do
Expand Down

0 comments on commit e4576de

Please sign in to comment.