-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Are there some reasons for this not being a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. json has no notion of characters, so strings are used |
||
":".to_string(), | ||
".".to_string(), | ||
"'".to_string(), | ||
"(".to_string(), | ||
]), | ||
all_commit_characters: None, | ||
completion_item: None, | ||
work_done_progress_options: WorkDoneProgressOptions { work_done_progress: None }, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -796,27 +796,26 @@ pub(crate) fn handle_completion( | |
let _p = profile::span("handle_completion"); | ||
let text_document_position = params.text_document_position.clone(); | ||
let position = from_proto::file_position(&snap, params.text_document_position)?; | ||
let completion_triggered_after_single_colon = { | ||
let mut res = false; | ||
if let Some(ctx) = params.context { | ||
if ctx.trigger_character.as_deref() == Some(":") { | ||
let source_file = snap.analysis.parse(position.file_id)?; | ||
let left_token = | ||
source_file.syntax().token_at_offset(position.offset).left_biased(); | ||
match left_token { | ||
Some(left_token) => res = left_token.kind() == T![:], | ||
None => res = true, | ||
} | ||
} | ||
let completion_trigger_character = params.context.and_then(|ctx| ctx.trigger_character); | ||
|
||
if Some(":") == completion_trigger_character.as_deref() { | ||
let source_file = snap.analysis.parse(position.file_id)?; | ||
let left_token = source_file.syntax().token_at_offset(position.offset).left_biased(); | ||
let completion_triggered_after_single_colon = match left_token { | ||
Some(left_token) => left_token.kind() == T![:], | ||
None => true, | ||
}; | ||
if completion_triggered_after_single_colon { | ||
return Ok(None); | ||
} | ||
res | ||
}; | ||
if completion_triggered_after_single_colon { | ||
return Ok(None); | ||
} | ||
|
||
let completion_config = &snap.config.completion(); | ||
let items = match snap.analysis.completions(completion_config, position)? { | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. I think |
||
)? { | ||
None => return Ok(None), | ||
Some(items) => items, | ||
}; | ||
|
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.