-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
fix: Retrigger visibility completion after parentheses #12412
Conversation
completions::r#type::complete_inferred_type(acc, ctx); | ||
completions::use_::complete_use_tree(acc, ctx); | ||
// prevent `(` from triggering unwanted completion noise | ||
if trigger_character != Some("(") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could put this down to individual tests but I think it's harder to understand and will just mess the codebase more. Current approach does not scale very well if we want to allow (
to trigger more completions though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ye I think putting it here for now is fine, depending on the final state of the completion architecture we might wanna move this somewhere else.
@@ -29,7 +29,12 @@ pub fn server_capabilities(config: &Config) -> ServerCapabilities { | |||
hover_provider: Some(HoverProviderCapability::Simple(true)), | |||
completion_provider: Some(CompletionOptions { | |||
resolve_provider: completions_resolve_provider(config.caps()), | |||
trigger_characters: Some(vec![":".to_string(), ".".to_string(), "'".to_string()]), | |||
trigger_characters: Some(vec![ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there some reasons for this not being a Vec<char>
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
json has no notion of characters, so strings are used
let items = match snap.analysis.completions( | ||
completion_config, | ||
position, | ||
completion_trigger_character.as_deref(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think trigger_character
is a state as the same as position
and putting it into config
would be weird.
|
Seems good to me overall, will wait on merging this until tomorrow though. |
@bors r+ |
📌 Commit 1b5f046 has been approved by |
☀️ Test successful - checks-actions |
close #12390
This PR add
(
to trigger_characters as discussed in original issue.Some questions:
ctx.trigger_character
fromparams.context
is the same asctx.original_token
inside actually completions?check_with_trigger_character
I added.($0)
( https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-completion/src/tests/fn_param.rs#L105 as an example), If I understand correctly they are not invoked outside tests at all?ctx.original_token
directly would break these tests as well as parsing trigger_character from fixture for now.(
triggering these cases?ide-completion
refactor #12144