mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 20:42:04 +00:00
Don't show incorrect completions after unsafe or visiblity node
This commit is contained in:
parent
1a8f76a224
commit
9ea6ee6b27
4 changed files with 38 additions and 42 deletions
|
@ -1,6 +1,7 @@
|
|||
//! This file provides snippet completions, like `pd` => `eprintln!(...)`.
|
||||
|
||||
use ide_db::helpers::SnippetCap;
|
||||
use syntax::T;
|
||||
|
||||
use crate::{
|
||||
context::PathCompletionContext, item::Builder, CompletionContext, CompletionItem,
|
||||
|
@ -35,9 +36,13 @@ pub(crate) fn complete_expr_snippet(acc: &mut Completions, ctx: &CompletionConte
|
|||
}
|
||||
|
||||
pub(crate) fn complete_item_snippet(acc: &mut Completions, ctx: &CompletionContext) {
|
||||
if !ctx.expects_item() {
|
||||
if !ctx.expects_item() || ctx.previous_token_is(T![unsafe]) {
|
||||
return;
|
||||
}
|
||||
if ctx.has_visibility_prev_sibling() {
|
||||
return; // technically we could do some of these snippet completions if we were to put the
|
||||
// attributes before the vis node.
|
||||
}
|
||||
let cap = match ctx.config.snippet_cap {
|
||||
Some(it) => it,
|
||||
None => return,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue