mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-27 06:14:55 +00:00
complete crate in use stmt
This commit is contained in:
parent
6f4c9303e4
commit
fc2d7d1e1f
@ -18,6 +18,16 @@ pub(super) fn complete_expr_keyword(acc: &mut Completions, ctx: &CompletionConte
|
||||
if !ctx.is_trivial_path {
|
||||
return;
|
||||
}
|
||||
|
||||
// complete keyword "crate" in use stmt
|
||||
if let (Some(use_item), None) = (&ctx.use_item_syntax, &ctx.path_prefix) {
|
||||
if use_item.use_tree().is_none() {
|
||||
CompletionItem::new(CompletionKind::Keyword, "crate")
|
||||
.kind(CompletionItemKind::Keyword)
|
||||
.add_to(acc);
|
||||
}
|
||||
}
|
||||
|
||||
let fn_def = match ctx.function_syntax {
|
||||
Some(it) => it,
|
||||
None => return,
|
||||
@ -269,4 +279,23 @@ mod tests {
|
||||
"#,
|
||||
)
|
||||
}
|
||||
|
||||
fn completes_crate_in_use_stmt() {
|
||||
check_keyword_completion(
|
||||
r"
|
||||
use <|>
|
||||
",
|
||||
r#"
|
||||
crate
|
||||
"#,
|
||||
);
|
||||
// No completion: lambda isolates control flow
|
||||
check_keyword_completion(
|
||||
r"
|
||||
use a<|>
|
||||
",
|
||||
r#"
|
||||
"#,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user