-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix: filter unnecessary completions after colon #13611
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
Changes from all commits
f26d548
a6d0e34
7a568f7
e1de04d
1ca5cb7
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 |
---|---|---|
|
@@ -28,7 +28,7 @@ use lsp_types::{ | |
use project_model::{ManifestPath, ProjectWorkspace, TargetKind}; | ||
use serde_json::json; | ||
use stdx::{format_to, never}; | ||
use syntax::{algo, ast, AstNode, TextRange, TextSize, T}; | ||
use syntax::{algo, ast, AstNode, TextRange, TextSize}; | ||
use vfs::AbsPathBuf; | ||
|
||
use crate::{ | ||
|
@@ -812,18 +812,6 @@ pub(crate) fn handle_completion( | |
let completion_trigger_character = | ||
params.context.and_then(|ctx| ctx.trigger_character).and_then(|s| s.chars().next()); | ||
|
||
if Some(':') == completion_trigger_character { | ||
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. It's possible to keep the filtering here but
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. the filtering definitely should not be happening here, so moving the handling into the ide-completion crate seems proper to me 👍 |
||
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); | ||
} | ||
} | ||
|
||
let completion_config = &snap.config.completion(); | ||
let items = match snap.analysis.completions( | ||
completion_config, | ||
|
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.
not sure if putting tests here (special.rs) is better than https://github.com/rust-lang/rust-analyzer/blob/45ec315e01dc8dd1146dfeb65f0ef6e5c2efed78/crates/ide-completion/src/tests.rs
I didn't find any
expect_test
usage there and not sure if there are any reasons for that