From fc0c5dfcd1c021d7e9662b20c7d394db65bf3388 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 14 May 2020 15:29:40 +0200 Subject: Put preselect items on top --- crates/rust-analyzer/src/to_proto.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'crates') diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs index 33c2fd595..2696ecac4 100644 --- a/crates/rust-analyzer/src/to_proto.rs +++ b/crates/rust-analyzer/src/to_proto.rs @@ -178,7 +178,9 @@ pub(crate) fn completion_item( }; if completion_item.score().is_some() { - res.preselect = Some(true) + res.preselect = Some(true); + // HACK: sort preselect items first + res.sort_text = Some(format!(" {}", completion_item.label())); } if completion_item.deprecated() { -- cgit v1.2.3 From acedad8134669b3deba48e59d28e62334ae5c4d4 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 14 May 2020 15:36:15 +0200 Subject: Minor --- crates/rust-analyzer/src/to_proto.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'crates') diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs index 2696ecac4..a8e2e535f 100644 --- a/crates/rust-analyzer/src/to_proto.rs +++ b/crates/rust-analyzer/src/to_proto.rs @@ -164,16 +164,6 @@ pub(crate) fn completion_item( additional_text_edits: Some(additional_text_edits), documentation: completion_item.documentation().map(documentation), deprecated: Some(completion_item.deprecated()), - command: if completion_item.trigger_call_info() { - let cmd = lsp_types::Command { - title: "triggerParameterHints".into(), - command: "editor.action.triggerParameterHints".into(), - arguments: None, - }; - Some(cmd) - } else { - None - }, ..Default::default() }; @@ -187,6 +177,14 @@ pub(crate) fn completion_item( res.tags = Some(vec![lsp_types::CompletionItemTag::Deprecated]) } + if completion_item.trigger_call_info() { + res.command = Some(lsp_types::Command { + title: "triggerParameterHints".into(), + command: "editor.action.triggerParameterHints".into(), + arguments: None, + }); + } + res.insert_text_format = Some(insert_text_format(completion_item.insert_text_format())); res -- cgit v1.2.3