Skip to content

Conversation

@popzxc
Copy link
Contributor

@popzxc popzxc commented Oct 17, 2020

Closes #5206

This is a second part of the fix (first was #5997).

This PR adds a new method to the CompletionContext: no_completion_required. If this method returns true, it essentially means that user is unlikely to expect any hints from the IDE at this cursor position.

Currently, checks for the following cases were added:

  • Previous item is fn: user creates a new function, names of existing functions won't be helpful. Exception for this case is impl Foo for Bar -- we must suggest trait function names.
  • User entered for _ i<|>: it's obviously going to be in keyword, any hints here will be confusing.

More checks may be added there later, but currently I've only figured two cases.

no_redundant_hints

@SomeoneToIgnore
Copy link
Contributor

I totally agree with the idea: we need a better way to filter out the completions if the position is not appropriate.

I'm not entirely convinced that the CompletionContext is a good place to have those cheks, but the PR is rather small and, what's more important, adds the tests for cases with no completions, so I like the idea to merge it.
I'll try to share my vision later today in zulip

Thank you.

bors r+

@bors
Copy link
Contributor

bors bot commented Oct 17, 2020

@bors bors bot merged commit b1315be into rust-lang:master Oct 17, 2020
@popzxc popzxc deleted the redundant-hints branch October 17, 2020 10:45
@SomeoneToIgnore
Copy link
Contributor

@matklad
Copy link
Contributor

matklad commented Oct 18, 2020

Previous item is fn: user creates a new function, names of existing functions won't be helpful.

fwiw, long-term we should plug "create from usage" into this.

ie, in

fn main() {
   no_such_fn_yet(92)
}

fn n

we should complete no_such_fn_yet(_: i32)

@popzxc
Copy link
Contributor Author

popzxc commented Oct 18, 2020

Yeah, that makes sense. As I wrote in zulip, I only see this as a temporary solution until completions management will become more picky about kinds of suggestions that will be presented to user.

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

Successfully merging this pull request may close these issues.

Bad hints and pop-up for for loops

4 participants