Only complete type annotations for patterns in function params

This commit is contained in:
Lukas Wirth 2021-08-14 18:18:18 +02:00
parent d07f4e4c35
commit bf918046fa
5 changed files with 67 additions and 19 deletions

View file

@ -4,7 +4,10 @@ use hir::{db::HirDatabase, HasAttrs, HasVisibility, Name, StructKind};
use ide_db::helpers::SnippetCap;
use itertools::Itertools;
use crate::{item::CompletionKind, render::RenderContext, CompletionItem, CompletionItemKind};
use crate::{
context::ParamKind, item::CompletionKind, render::RenderContext, CompletionItem,
CompletionItemKind,
};
pub(crate) fn render_struct_pat(
ctx: RenderContext<'_>,
@ -83,7 +86,7 @@ fn render_pat(
_ => return None,
};
if ctx.completion.is_param {
if ctx.completion.is_param == Some(ParamKind::Function) {
pat.push(':');
pat.push(' ');
pat.push_str(name);

View file

@ -58,11 +58,6 @@ fn render_literal(
_ => return None,
};
if ctx.completion.is_param {
literal.push(':');
literal.push(' ');
literal.push_str(name);
}
if ctx.snippet_cap().is_some() {
literal.push_str("$0");
}