Only run completion functions if their corresponding context is active

This commit is contained in:
Lukas Wirth 2022-06-17 23:36:39 +02:00
parent d97a8ee865
commit 00fdb4a3d8
29 changed files with 562 additions and 397 deletions

View file

@ -6,7 +6,9 @@ use itertools::Itertools;
use syntax::SmolStr;
use crate::{
context::{ParamKind, PathCompletionCtx, PatternContext},
context::{
IdentContext, NameRefContext, NameRefKind, ParamKind, PathCompletionCtx, PatternContext,
},
render::{variant::visible_fields, RenderContext},
CompletionItem, CompletionItemKind,
};
@ -78,8 +80,11 @@ fn render_pat(
fields_omitted: bool,
) -> Option<String> {
let has_call_parens = matches!(
ctx.completion.path_context(),
Some(PathCompletionCtx { has_call_parens: true, .. })
ctx.completion.ident_ctx,
IdentContext::NameRef(NameRefContext {
kind: Some(NameRefKind::Path(PathCompletionCtx { has_call_parens: true, .. })),
..
})
);
let mut pat = match kind {
StructKind::Tuple if !has_call_parens => {