Merge #6127
6127: Correctly complete items with leading underscore r=SomeoneToIgnore a=fmease Fixes #6091. Let me know if the test is placed into the right file or if it is even desired. Co-authored-by: León Orell Valerian Liehr <liehr.exchange@gmx.net>
This commit is contained in:
commit
44587d1bfc
2 changed files with 23 additions and 2 deletions
|
@ -267,6 +267,26 @@ fn quux() { <|> }
|
|||
);
|
||||
}
|
||||
|
||||
/// Regression test for issue #6091.
|
||||
#[test]
|
||||
fn correctly_completes_module_items_prefixed_with_underscore() {
|
||||
check_edit(
|
||||
"_alpha",
|
||||
r#"
|
||||
fn main() {
|
||||
_<|>
|
||||
}
|
||||
fn _alpha() {}
|
||||
"#,
|
||||
r#"
|
||||
fn main() {
|
||||
_alpha()$0
|
||||
}
|
||||
fn _alpha() {}
|
||||
"#,
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn completes_extern_prelude() {
|
||||
check(
|
||||
|
|
|
@ -221,10 +221,11 @@ impl<'a> CompletionContext<'a> {
|
|||
Some(ctx)
|
||||
}
|
||||
|
||||
// The range of the identifier that is being completed.
|
||||
/// The range of the identifier that is being completed.
|
||||
pub(crate) fn source_range(&self) -> TextRange {
|
||||
// check kind of macro-expanded token, but use range of original token
|
||||
if self.token.kind() == IDENT || self.token.kind().is_keyword() {
|
||||
let kind = self.token.kind();
|
||||
if kind == IDENT || kind == UNDERSCORE || kind.is_keyword() {
|
||||
mark::hit!(completes_if_prefix_is_keyword);
|
||||
self.original_token.text_range()
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue