Skip to content

Commit 87470e8

Browse files
bors[bot]matklad
andauthored
Merge #4456
4456: Sort preselect items on top r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
2 parents d7c451e + acedad8 commit 87470e8

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

crates/rust-analyzer/src/to_proto.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -164,27 +164,27 @@ pub(crate) fn completion_item(
164164
additional_text_edits: Some(additional_text_edits),
165165
documentation: completion_item.documentation().map(documentation),
166166
deprecated: Some(completion_item.deprecated()),
167-
command: if completion_item.trigger_call_info() {
168-
let cmd = lsp_types::Command {
169-
title: "triggerParameterHints".into(),
170-
command: "editor.action.triggerParameterHints".into(),
171-
arguments: None,
172-
};
173-
Some(cmd)
174-
} else {
175-
None
176-
},
177167
..Default::default()
178168
};
179169

180170
if completion_item.score().is_some() {
181-
res.preselect = Some(true)
171+
res.preselect = Some(true);
172+
// HACK: sort preselect items first
173+
res.sort_text = Some(format!(" {}", completion_item.label()));
182174
}
183175

184176
if completion_item.deprecated() {
185177
res.tags = Some(vec![lsp_types::CompletionItemTag::Deprecated])
186178
}
187179

180+
if completion_item.trigger_call_info() {
181+
res.command = Some(lsp_types::Command {
182+
title: "triggerParameterHints".into(),
183+
command: "editor.action.triggerParameterHints".into(),
184+
arguments: None,
185+
});
186+
}
187+
188188
res.insert_text_format = Some(insert_text_format(completion_item.insert_text_format()));
189189

190190
res

0 commit comments

Comments
 (0)