From 21f40f2b8f2d2ce19c2bc69201e99503a8d15e04 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 6 Mar 2020 17:44:30 +0100 Subject: Fix comment order --- crates/ra_ide/src/completion/presentation.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/ra_ide/src') diff --git a/crates/ra_ide/src/completion/presentation.rs b/crates/ra_ide/src/completion/presentation.rs index dac232a85..e623c47ec 100644 --- a/crates/ra_ide/src/completion/presentation.rs +++ b/crates/ra_ide/src/completion/presentation.rs @@ -103,7 +103,7 @@ impl Completions { } }; - // If not an import, add parenthesis automatically. + // Add `<>` for generic types if ctx.is_path_type && !ctx.has_type_args && ctx.db.feature_flags.get("completion.insertion.add-call-parenthesis") @@ -211,7 +211,7 @@ impl Completions { .set_deprecated(is_deprecated(func, ctx.db)) .detail(function_signature.to_string()); - // Add `<>` for generic types + // If not an import, add parenthesis automatically. if ctx.use_item_syntax.is_none() && !ctx.is_call && ctx.db.feature_flags.get("completion.insertion.add-call-parenthesis") -- cgit v1.2.3 From 4e7f6c235489eb40c85bb73e75beead3ea7f08c7 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 6 Mar 2020 17:51:10 +0100 Subject: Feature flag for arg snippets --- crates/ra_ide/src/completion/presentation.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'crates/ra_ide/src') diff --git a/crates/ra_ide/src/completion/presentation.rs b/crates/ra_ide/src/completion/presentation.rs index e623c47ec..841d36c8f 100644 --- a/crates/ra_ide/src/completion/presentation.rs +++ b/crates/ra_ide/src/completion/presentation.rs @@ -221,16 +221,25 @@ impl Completions { let (snippet, label) = if params.is_empty() || has_self_param && params.len() == 1 { (format!("{}()$0", name), format!("{}()", name)) } else { - let to_skip = if has_self_param { 1 } else { 0 }; - let function_params_snippet = - join( + let snippet = if ctx + .db + .feature_flags + .get("completion.insertion.add-argument-sippets") + { + let to_skip = if has_self_param { 1 } else { 0 }; + let function_params_snippet = join( function_signature.parameter_names.iter().skip(to_skip).enumerate().map( |(index, param_name)| format!("${{{}:{}}}", index + 1, param_name), ), ) .separator(", ") .to_string(); - (format!("{}({})$0", name, function_params_snippet), format!("{}(…)", name)) + format!("{}({})$0", name, function_params_snippet) + } else { + format!("{}($0)", name) + }; + + (snippet, format!("{}(…)", name)) }; builder = builder.lookup_by(name).label(label).insert_snippet(snippet); } -- cgit v1.2.3 From 3ff170d65872d9965c4bd88184701d957f23570e Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 6 Mar 2020 17:56:51 +0100 Subject: Trigger parameter info automatically See https://github.com/Microsoft/vscode/issues/64023 --- crates/ra_ide/src/completion/completion_item.rs | 15 +++++++++++++++ crates/ra_ide/src/completion/presentation.rs | 1 + 2 files changed, 16 insertions(+) (limited to 'crates/ra_ide/src') diff --git a/crates/ra_ide/src/completion/completion_item.rs b/crates/ra_ide/src/completion/completion_item.rs index 61867c0ff..19bbb2517 100644 --- a/crates/ra_ide/src/completion/completion_item.rs +++ b/crates/ra_ide/src/completion/completion_item.rs @@ -47,6 +47,10 @@ pub struct CompletionItem { /// Whether this item is marked as deprecated deprecated: bool, + + /// If completing a function call, ask the editor to show parameter popup + /// after completion. + trigger_call_info: bool, } // We use custom debug for CompletionItem to make `insta`'s diffs more readable. @@ -139,6 +143,7 @@ impl CompletionItem { kind: None, text_edit: None, deprecated: None, + trigger_call_info: None, } } /// What user sees in pop-up in the UI. @@ -177,6 +182,10 @@ impl CompletionItem { pub fn deprecated(&self) -> bool { self.deprecated } + + pub fn trigger_call_info(&self) -> bool { + self.trigger_call_info + } } /// A helper to make `CompletionItem`s. @@ -193,6 +202,7 @@ pub(crate) struct Builder { kind: Option, text_edit: Option, deprecated: Option, + trigger_call_info: Option, } impl Builder { @@ -221,6 +231,7 @@ impl Builder { kind: self.kind, completion_kind: self.completion_kind, deprecated: self.deprecated.unwrap_or(false), + trigger_call_info: self.trigger_call_info.unwrap_or(false), } } pub(crate) fn lookup_by(mut self, lookup: impl Into) -> Builder { @@ -271,6 +282,10 @@ impl Builder { self.deprecated = Some(deprecated); self } + pub(crate) fn trigger_call_info(mut self) -> Builder { + self.trigger_call_info = Some(true); + self + } } impl<'a> Into for Builder { diff --git a/crates/ra_ide/src/completion/presentation.rs b/crates/ra_ide/src/completion/presentation.rs index 841d36c8f..d6196a5ce 100644 --- a/crates/ra_ide/src/completion/presentation.rs +++ b/crates/ra_ide/src/completion/presentation.rs @@ -221,6 +221,7 @@ impl Completions { let (snippet, label) = if params.is_empty() || has_self_param && params.len() == 1 { (format!("{}()$0", name), format!("{}()", name)) } else { + builder = builder.trigger_call_info(); let snippet = if ctx .db .feature_flags -- cgit v1.2.3