diff options
| author | yue4u <github@yue.coffee> | 2022-11-27 02:39:38 +0900 |
|---|---|---|
| committer | yue4u <github@yue.coffee> | 2022-11-27 02:39:38 +0900 |
| commit | 1ca5cb7ed9928fad4222cb26727da41ff9ac148f (patch) | |
| tree | 51f689a5ca090cab085c514a5c7c0956588c05fb | |
| parent | e1de04d60ceff530295f57ae47a65e9c05716bbf (diff) | |
| download | rust-1ca5cb7ed9928fad4222cb26727da41ff9ac148f.tar.gz rust-1ca5cb7ed9928fad4222cb26727da41ff9ac148f.zip | |
fix: also exclude 2 coloncolon in a row
| -rw-r--r-- | crates/ide-completion/src/context.rs | 9 | ||||
| -rw-r--r-- | crates/ide-completion/src/tests/special.rs | 8 |
2 files changed, 14 insertions, 3 deletions
diff --git a/crates/ide-completion/src/context.rs b/crates/ide-completion/src/context.rs index 0e3b677f2d6..aa77f449530 100644 --- a/crates/ide-completion/src/context.rs +++ b/crates/ide-completion/src/context.rs @@ -581,9 +581,14 @@ impl<'a> CompletionContext<'a> { return None; } - // has 3 colon in a row + // has 3 colon or 2 coloncolon 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) { + // and https://github.com/rust-lang/rust-analyzer/pull/13611#discussion_r1032812751 + if prev_token + .prev_token() + .map(|t| t.kind() == T![:] || t.kind() == T![::]) + .unwrap_or(false) + { return None; } } diff --git a/crates/ide-completion/src/tests/special.rs b/crates/ide-completion/src/tests/special.rs index 0e59f4ec541..cad4af4937d 100644 --- a/crates/ide-completion/src/tests/special.rs +++ b/crates/ide-completion/src/tests/special.rs @@ -967,11 +967,17 @@ fn foo { crate:$0 } } #[test] -fn no_completions_in_after_tripple_colon() { +fn no_completions_in_invalid_path() { check( r#" fn foo { crate:::$0 } "#, expect![""], ); + check( + r#" +fn foo { crate::::$0 } +"#, + expect![""], + ) } |
