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

Autocompletion no longer counts qualified imports #2082

Closed
Akhristenko opened this issue Aug 6, 2021 · 7 comments · Fixed by #2332
Closed

Autocompletion no longer counts qualified imports #2082

Akhristenko opened this issue Aug 6, 2021 · 7 comments · Fixed by #2332
Assignees
Labels
component: ghcide type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@Akhristenko
Copy link

Steps to reproduce

I have 2 modules

module MyModule (myid) where

myid :: a -> a
myid a = a
module MyModuleB (myid') where

import qualified MyModule

myid' :: a -> a
myid' = MyModule.myid

I delete myid in second module and invoke autocompletion when cursor placed after MyModule.

Expected behaviour

In autocompletion list i see only functions from MyModule

Actual behaviour

In autocompletion list i see all function from all modules

@pepeiborra
Copy link
Collaborator

Thanks for reporting, this is likely a regression after #2040

@pepeiborra pepeiborra self-assigned this Aug 6, 2021
@jneira jneira added type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. status: regression test needed component: ghcide labels Aug 6, 2021
@pepeiborra
Copy link
Collaborator

I'm not so sure this is a regression anymore. It's actually a new feature! Previously autocompletion only suggested imported identifiers, now it suggests also unimported identifiers and automatically inserts a new import if necessary. Qualifiers are no longer used only for filtering, but also to inform the format of the inserted import. However qualifiers are still used for filtering, and list of completions should put the functions from current imports first. Can you confirm whether this is the case for you?

@Akhristenko
Copy link
Author

However qualifiers are still used for filtering, and list of completions should put the functions from current imports first.

It's not true, at least on version 1.3.0 it show all names in alphabetical order. But if hls will showing names imported in qualifiers ordered alphabetically before all other names it will solve this issue.

@Akhristenko
Copy link
Author

ideally i would like this behavior:

  • if we invoke autocomplete on qualifier, which was not imported, we see all functions and autoimport perform after we select one of them.
  • if we invoke autocomplete on qualifier, which was imported, we see only functions which was imported. But if we invoke autocomplete second time we see all functions and can autoimport one of them.

@alexnaspo
Copy link
Contributor

I see a decent path forward on this one, is it worth picking up? @pepeiborra

@pepeiborra
Copy link
Collaborator

I would start with a set of tests demonstrating the problem, and then we can discuss what needs to be done to enforce the behaviour that I outlined above.

Implementing the behaviour that @Akhristenko suggested is not something I would recommend. "If we invoke autocomplete a second time" is not a condition that the LSP server can detect.

@jneira
Copy link
Member

jneira commented Nov 16, 2021

Closed by #2332

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: ghcide type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants