aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/rust-analyzer/src/conv.rs21
-rw-r--r--crates/rust-analyzer/src/main_loop/handlers.rs7
2 files changed, 10 insertions, 18 deletions
diff --git a/crates/rust-analyzer/src/conv.rs b/crates/rust-analyzer/src/conv.rs
index 7e30956cc..098ee369c 100644
--- a/crates/rust-analyzer/src/conv.rs
+++ b/crates/rust-analyzer/src/conv.rs
@@ -9,10 +9,10 @@ use lsp_types::{
9 TextDocumentPositionParams, Url, VersionedTextDocumentIdentifier, WorkspaceEdit, 9 TextDocumentPositionParams, Url, VersionedTextDocumentIdentifier, WorkspaceEdit,
10}; 10};
11use ra_ide::{ 11use ra_ide::{
12 translate_offset_with_edit, CompletionItem, CompletionItemKind, CompletionScore, FileId, 12 translate_offset_with_edit, CompletionItem, CompletionItemKind, FileId, FilePosition,
13 FilePosition, FileRange, FileSystemEdit, Fold, FoldKind, Highlight, HighlightModifier, 13 FileRange, FileSystemEdit, Fold, FoldKind, Highlight, HighlightModifier, HighlightTag,
14 HighlightTag, InlayHint, InlayKind, InsertTextFormat, LineCol, LineIndex, NavigationTarget, 14 InlayHint, InlayKind, InsertTextFormat, LineCol, LineIndex, NavigationTarget, RangeInfo,
15 RangeInfo, ReferenceAccess, Severity, SourceChange, SourceFileEdit, 15 ReferenceAccess, Severity, SourceChange, SourceFileEdit,
16}; 16};
17use ra_syntax::{SyntaxKind, TextRange, TextUnit}; 17use ra_syntax::{SyntaxKind, TextRange, TextUnit};
18use ra_text_edit::{AtomTextEdit, TextEdit}; 18use ra_text_edit::{AtomTextEdit, TextEdit};
@@ -114,10 +114,10 @@ impl Conv for Severity {
114 } 114 }
115} 115}
116 116
117impl ConvWith<(&LineIndex, LineEndings, &mut usize)> for CompletionItem { 117impl ConvWith<(&LineIndex, LineEndings)> for CompletionItem {
118 type Output = ::lsp_types::CompletionItem; 118 type Output = ::lsp_types::CompletionItem;
119 119
120 fn conv_with(self, ctx: (&LineIndex, LineEndings, &mut usize)) -> ::lsp_types::CompletionItem { 120 fn conv_with(self, ctx: (&LineIndex, LineEndings)) -> ::lsp_types::CompletionItem {
121 let mut additional_text_edits = Vec::new(); 121 let mut additional_text_edits = Vec::new();
122 let mut text_edit = None; 122 let mut text_edit = None;
123 // LSP does not allow arbitrary edits in completion, so we have to do a 123 // LSP does not allow arbitrary edits in completion, so we have to do a
@@ -165,13 +165,8 @@ impl ConvWith<(&LineIndex, LineEndings, &mut usize)> for CompletionItem {
165 ..Default::default() 165 ..Default::default()
166 }; 166 };
167 167
168 if let Some(score) = self.score() { 168 if self.score().is_some() {
169 match score { 169 res.preselect = Some(true)
170 CompletionScore::TypeAndNameMatch => res.preselect = Some(true),
171 CompletionScore::TypeMatch => {}
172 }
173 res.sort_text = Some(format!("{:02}", *ctx.2));
174 *ctx.2 += 1;
175 } 170 }
176 171
177 if self.deprecated() { 172 if self.deprecated() {
diff --git a/crates/rust-analyzer/src/main_loop/handlers.rs b/crates/rust-analyzer/src/main_loop/handlers.rs
index ee669f383..41d9fe344 100644
--- a/crates/rust-analyzer/src/main_loop/handlers.rs
+++ b/crates/rust-analyzer/src/main_loop/handlers.rs
@@ -423,11 +423,8 @@ pub fn handle_completion(
423 }; 423 };
424 let line_index = world.analysis().file_line_index(position.file_id)?; 424 let line_index = world.analysis().file_line_index(position.file_id)?;
425 let line_endings = world.file_line_endings(position.file_id); 425 let line_endings = world.file_line_endings(position.file_id);
426 let mut count_sort_text_item = 0usize; 426 let items: Vec<CompletionItem> =
427 let items: Vec<CompletionItem> = items 427 items.into_iter().map(|item| item.conv_with((&line_index, line_endings))).collect();
428 .into_iter()
429 .map(|item| item.conv_with((&line_index, line_endings, &mut count_sort_text_item)))
430 .collect();
431 428
432 Ok(Some(items.into())) 429 Ok(Some(items.into()))
433} 430}