mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-15 06:33:58 +00:00
Show macro_rules
snippet in blocks
This commit is contained in:
parent
0b49c93b91
commit
0060d5977d
2 changed files with 27 additions and 20 deletions
|
@ -43,7 +43,7 @@ pub(crate) fn complete_expr_snippet(acc: &mut Completions, ctx: &CompletionConte
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn complete_item_snippet(acc: &mut Completions, ctx: &CompletionContext) {
|
pub(crate) fn complete_item_snippet(acc: &mut Completions, ctx: &CompletionContext) {
|
||||||
if !ctx.expects_item()
|
if !(ctx.expects_item() || ctx.has_block_expr_parent())
|
||||||
|| ctx.previous_token_is(T![unsafe])
|
|| ctx.previous_token_is(T![unsafe])
|
||||||
|| ctx.path_qual().is_some()
|
|| ctx.path_qual().is_some()
|
||||||
|| ctx.has_impl_or_trait_prev_sibling()
|
|| ctx.has_impl_or_trait_prev_sibling()
|
||||||
|
@ -63,6 +63,8 @@ pub(crate) fn complete_item_snippet(acc: &mut Completions, ctx: &CompletionConte
|
||||||
add_custom_completions(acc, ctx, cap, SnippetScope::Item);
|
add_custom_completions(acc, ctx, cap, SnippetScope::Item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test-related snippets shouldn't be shown in blocks.
|
||||||
|
if !ctx.has_block_expr_parent() {
|
||||||
let mut item = snippet(
|
let mut item = snippet(
|
||||||
ctx,
|
ctx,
|
||||||
cap,
|
cap,
|
||||||
|
@ -93,6 +95,7 @@ fn ${1:feature}() {
|
||||||
);
|
);
|
||||||
item.lookup_by("tfn");
|
item.lookup_by("tfn");
|
||||||
item.add_to(acc);
|
item.add_to(acc);
|
||||||
|
}
|
||||||
|
|
||||||
let item = snippet(
|
let item = snippet(
|
||||||
ctx,
|
ctx,
|
||||||
|
|
|
@ -153,6 +153,7 @@ impl Unit {
|
||||||
kw return
|
kw return
|
||||||
sn pd
|
sn pd
|
||||||
sn ppd
|
sn ppd
|
||||||
|
sn macro_rules
|
||||||
kw self
|
kw self
|
||||||
kw super
|
kw super
|
||||||
kw crate
|
kw crate
|
||||||
|
@ -246,6 +247,7 @@ fn complete_in_block() {
|
||||||
kw return
|
kw return
|
||||||
sn pd
|
sn pd
|
||||||
sn ppd
|
sn ppd
|
||||||
|
sn macro_rules
|
||||||
kw self
|
kw self
|
||||||
kw super
|
kw super
|
||||||
kw crate
|
kw crate
|
||||||
|
@ -293,6 +295,7 @@ fn complete_after_if_expr() {
|
||||||
kw return
|
kw return
|
||||||
sn pd
|
sn pd
|
||||||
sn ppd
|
sn ppd
|
||||||
|
sn macro_rules
|
||||||
kw self
|
kw self
|
||||||
kw super
|
kw super
|
||||||
kw crate
|
kw crate
|
||||||
|
@ -366,6 +369,7 @@ fn completes_in_loop_ctx() {
|
||||||
kw return
|
kw return
|
||||||
sn pd
|
sn pd
|
||||||
sn ppd
|
sn ppd
|
||||||
|
sn macro_rules
|
||||||
kw self
|
kw self
|
||||||
kw super
|
kw super
|
||||||
kw crate
|
kw crate
|
||||||
|
|
Loading…
Reference in a new issue