mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 21:43:37 +00:00
fix: only special casing 3 colon in a row
This commit is contained in:
parent
7a568f7f95
commit
e1de04d60c
2 changed files with 4 additions and 26 deletions
|
@ -581,7 +581,9 @@ impl<'a> CompletionContext<'a> {
|
|||
return None;
|
||||
}
|
||||
|
||||
if !is_prev_token_valid_path_start_or_segment(&prev_token) {
|
||||
// has 3 colon in a row
|
||||
// special casing this as per discussion in https://github.com/rust-lang/rust-analyzer/pull/13611#discussion_r1031845205
|
||||
if prev_token.prev_token().map(|t| t.kind() == T![:]).unwrap_or(false) {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
|
@ -637,24 +639,6 @@ impl<'a> CompletionContext<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
fn is_prev_token_valid_path_start_or_segment(token: &SyntaxToken) -> bool {
|
||||
if let Some(prev_token) = token.prev_token() {
|
||||
// token before coloncolon is invalid
|
||||
if !matches!(
|
||||
prev_token.kind(),
|
||||
// trival
|
||||
WHITESPACE | COMMENT
|
||||
// PathIdentSegment
|
||||
| IDENT | T![super] | T![self] | T![Self] | T![crate]
|
||||
// QualifiedPath
|
||||
| T![>]
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
const OP_TRAIT_LANG_NAMES: &[&str] = &[
|
||||
"add_assign",
|
||||
"add",
|
||||
|
|
|
@ -967,16 +967,10 @@ fn foo { crate:$0 }
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn no_completions_in_invalid_path() {
|
||||
fn no_completions_in_after_tripple_colon() {
|
||||
check(
|
||||
r#"
|
||||
fn foo { crate:::$0 }
|
||||
"#,
|
||||
expect![""],
|
||||
);
|
||||
check(
|
||||
r#"
|
||||
fn foo { crate::::$0 }
|
||||
"#,
|
||||
expect![""],
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue