mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
Merge #5295
5295: Complete params in nested fns r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
5a195001d7
1 changed files with 16 additions and 5 deletions
|
@ -18,16 +18,12 @@ pub(super) fn complete_fn_param(acc: &mut Completions, ctx: &CompletionContext)
|
|||
}
|
||||
|
||||
let mut params = FxHashMap::default();
|
||||
let mut me = None;
|
||||
let me = ctx.token.ancestors().find_map(ast::FnDef::cast);
|
||||
for node in ctx.token.parent().ancestors() {
|
||||
let items = match_ast! {
|
||||
match node {
|
||||
ast::SourceFile(it) => it.items(),
|
||||
ast::ItemList(it) => it.items(),
|
||||
ast::FnDef(it) => {
|
||||
me = Some(it);
|
||||
continue;
|
||||
},
|
||||
_ => continue,
|
||||
}
|
||||
};
|
||||
|
@ -43,6 +39,7 @@ pub(super) fn complete_fn_param(acc: &mut Completions, ctx: &CompletionContext)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
params
|
||||
.into_iter()
|
||||
.filter_map(|(label, param)| {
|
||||
|
@ -111,4 +108,18 @@ pub(crate) trait SourceRoot {
|
|||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn completes_param_in_inner_function() {
|
||||
check(
|
||||
r#"
|
||||
fn outer(text: String) {
|
||||
fn inner(<|>)
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
bn text: String
|
||||
"#]],
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue