mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-15 22:54:00 +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;
|
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;
|
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] = &[
|
const OP_TRAIT_LANG_NAMES: &[&str] = &[
|
||||||
"add_assign",
|
"add_assign",
|
||||||
"add",
|
"add",
|
||||||
|
|
|
@ -967,16 +967,10 @@ fn foo { crate:$0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn no_completions_in_invalid_path() {
|
fn no_completions_in_after_tripple_colon() {
|
||||||
check(
|
check(
|
||||||
r#"
|
r#"
|
||||||
fn foo { crate:::$0 }
|
fn foo { crate:::$0 }
|
||||||
"#,
|
|
||||||
expect![""],
|
|
||||||
);
|
|
||||||
check(
|
|
||||||
r#"
|
|
||||||
fn foo { crate::::$0 }
|
|
||||||
"#,
|
"#,
|
||||||
expect![""],
|
expect![""],
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue