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

Prefer to auto complete in scope word rather than import #18530

Open
baxterjo opened this issue Nov 18, 2024 · 5 comments
Open

Prefer to auto complete in scope word rather than import #18530

baxterjo opened this issue Nov 18, 2024 · 5 comments
Labels
A-completion autocompletion C-feature Category: feature request

Comments

@baxterjo
Copy link

I see a lot of issues about the scope of one import vs another. But I'm experiencing a lot of frustration when using the auto complete feature for in scope variables competing with auto import.

Example

Image

This seems completely unexpected. I would assume local vars should always be prefered over importing a new module in terms of auto complete.

@baxterjo baxterjo added the C-feature Category: feature request label Nov 18, 2024
@ChayimFriedman2
Copy link
Contributor

Hmm... I'm not sure it would be better. This is an exact match after all.

@lnicola
Copy link
Member

lnicola commented Nov 19, 2024

I'd probably prefer a prefix match to rank above an exact match flyimport, because if it's wrong, it's only wrong once (assuming you actually import it).

@lnicola lnicola added the A-completion autocompletion label Nov 19, 2024
@baxterjo
Copy link
Author

baxterjo commented Nov 21, 2024

Hmm... I'm not sure it would be better. This is an exact match after all.

Exact match makes sense if from a pure text search perspective. But I would argue that DX and context matter here.

The primary goal should be to do the least work possible first, then to provide a good match. Matches that take no action other than autocomplete should be ranked above matches that both autocomplete and import, regardless of the exactness of the match. Because if the match with imports happens to be wrong, the developer must go to the top of the file and undo what rust-analyzer did before continuing their work. This is very disruptive to workflow.

@baxterjo
Copy link
Author

I'd probably prefer a prefix match to rank above an exact match flyimport, because if it's wrong, it's only wrong once (assuming you actually import it).

I don't fully understand what you mean in the second half of this comment, but I think we're on the same page?

@ChayimFriedman2
Copy link
Contributor

I assume that developers rarely accept the wrong completion. Also if they do, it's a matter of Undo, no need to go to the top of the file. But the argument @lnicola provided is convincing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-completion autocompletion C-feature Category: feature request
Projects
None yet
Development

No branches or pull requests

3 participants