Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress exact matches in identifier completions #1282

Open
jwortmann opened this issue May 2, 2024 · 1 comment
Open

Suppress exact matches in identifier completions #1282

jwortmann opened this issue May 2, 2024 · 1 comment

Comments

@jwortmann
Copy link
Contributor

When you type a new identifier, for example a struct or function definition, there is one completion item with the exact part of the name that you have already typed. This will update after each key stroke, because CompletionList.isIncomplete is always set to true, so the client will continuously re-request completions:

return CompletionList(true, unique(values(state.completions)))

Example screenshot from VSCode:

completion

If you confirm this completion, nothing happens because it just replaces the typed identifier, which already was the exact same text. Even if you haven't typed the end yet, it won't be inserted for you. So I think this completion item is pretty useless and could be removed. (In Sublime the popup heavily flickers if there are no other completions visible, and I wasn't able to find a good workaround for that on the client side).

I was able to remove the completion by excluding exact matches at

if is_completion_match(n[1], spartial)

like this:

--- a/src/requests/completions.jl
+++ b/src/requests/completions.jl
@@ -259,7 +259,7 @@ function collect_completions(x::StaticLint.Scope, spartial, state::CompletionSta
         possible_names = String[]
         for n in x.names
             resize!(possible_names, 0)
-            if is_completion_match(n[1], spartial)
+            if is_completion_match(n[1], spartial) && n[1] != spartial
                 push!(possible_names, n[1])
             end
             if (nn = string_macro_altname(n[1]); nn !== nothing) && is_completion_match(nn, spartial)

Although I don't know where the x.names exactly come from or whether there is a better solution.

@pfitzseb
Copy link
Member

pfitzseb commented May 6, 2024

This is an ok solution for the symptom, but imho the more correct fix here is to not offer the current binding. Otherwise you wouldn't get these somewhat useful completions:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants