]> git.lizzy.rs Git - rust.git/commitdiff
Don't set sortText
authorAleksey Kladov <aleksey.kladov@gmail.com>
Thu, 23 Apr 2020 23:52:26 +0000 (01:52 +0200)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Thu, 23 Apr 2020 23:53:37 +0000 (01:53 +0200)
I might be reading this wrong, but it looks like we are setting it to
essentially arbitrary string at the moment, as there are no defined
order on the items in the *set* of completions.

crates/rust-analyzer/src/conv.rs
crates/rust-analyzer/src/main_loop/handlers.rs

index 7e30956cc30302b504e5fa85db764b04ad793a43..098ee369c2adb95af5d6c33b673539b04cd49fbf 100644 (file)
@@ -9,10 +9,10 @@
     TextDocumentPositionParams, Url, VersionedTextDocumentIdentifier, WorkspaceEdit,
 };
 use ra_ide::{
-    translate_offset_with_edit, CompletionItem, CompletionItemKind, CompletionScore, FileId,
-    FilePosition, FileRange, FileSystemEdit, Fold, FoldKind, Highlight, HighlightModifier,
-    HighlightTag, InlayHint, InlayKind, InsertTextFormat, LineCol, LineIndex, NavigationTarget,
-    RangeInfo, ReferenceAccess, Severity, SourceChange, SourceFileEdit,
+    translate_offset_with_edit, CompletionItem, CompletionItemKind, FileId, FilePosition,
+    FileRange, FileSystemEdit, Fold, FoldKind, Highlight, HighlightModifier, HighlightTag,
+    InlayHint, InlayKind, InsertTextFormat, LineCol, LineIndex, NavigationTarget, RangeInfo,
+    ReferenceAccess, Severity, SourceChange, SourceFileEdit,
 };
 use ra_syntax::{SyntaxKind, TextRange, TextUnit};
 use ra_text_edit::{AtomTextEdit, TextEdit};
@@ -114,10 +114,10 @@ fn conv(self) -> DiagnosticSeverity {
     }
 }
 
-impl ConvWith<(&LineIndex, LineEndings, &mut usize)> for CompletionItem {
+impl ConvWith<(&LineIndex, LineEndings)> for CompletionItem {
     type Output = ::lsp_types::CompletionItem;
 
-    fn conv_with(self, ctx: (&LineIndex, LineEndings, &mut usize)) -> ::lsp_types::CompletionItem {
+    fn conv_with(self, ctx: (&LineIndex, LineEndings)) -> ::lsp_types::CompletionItem {
         let mut additional_text_edits = Vec::new();
         let mut text_edit = None;
         // LSP does not allow arbitrary edits in completion, so we have to do a
@@ -165,13 +165,8 @@ fn conv_with(self, ctx: (&LineIndex, LineEndings, &mut usize)) -> ::lsp_types::C
             ..Default::default()
         };
 
-        if let Some(score) = self.score() {
-            match score {
-                CompletionScore::TypeAndNameMatch => res.preselect = Some(true),
-                CompletionScore::TypeMatch => {}
-            }
-            res.sort_text = Some(format!("{:02}", *ctx.2));
-            *ctx.2 += 1;
+        if self.score().is_some() {
+            res.preselect = Some(true)
         }
 
         if self.deprecated() {
index ee669f3832169130a980a7df0bb2bee75e60fc0c..41d9fe344d4d97f0ad155968ff2f0d30e909e0e9 100644 (file)
@@ -423,11 +423,8 @@ pub fn handle_completion(
     };
     let line_index = world.analysis().file_line_index(position.file_id)?;
     let line_endings = world.file_line_endings(position.file_id);
-    let mut count_sort_text_item = 0usize;
-    let items: Vec<CompletionItem> = items
-        .into_iter()
-        .map(|item| item.conv_with((&line_index, line_endings, &mut count_sort_text_item)))
-        .collect();
+    let items: Vec<CompletionItem> =
+        items.into_iter().map(|item| item.conv_with((&line_index, line_endings))).collect();
 
     Ok(Some(items.into()))
 }