diff options
author | Aleksey Kladov <[email protected]> | 2020-04-24 00:52:26 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-04-24 00:53:37 +0100 |
commit | 88d243c742ecd724372c4293b6b6ea293bae2d17 (patch) | |
tree | 2dd1fe075f1343c2a1bfaa03f800d4d3d53809ee /crates | |
parent | 647683b9bbbbac209b7cb1d2d1c2e1d50ffdfd11 (diff) |
Don't set sortText
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.
Diffstat (limited to 'crates')
-rw-r--r-- | crates/rust-analyzer/src/conv.rs | 21 | ||||
-rw-r--r-- | crates/rust-analyzer/src/main_loop/handlers.rs | 7 |
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 | }; |
11 | use ra_ide::{ | 11 | use 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 | }; |
17 | use ra_syntax::{SyntaxKind, TextRange, TextUnit}; | 17 | use ra_syntax::{SyntaxKind, TextRange, TextUnit}; |
18 | use ra_text_edit::{AtomTextEdit, TextEdit}; | 18 | use ra_text_edit::{AtomTextEdit, TextEdit}; |
@@ -114,10 +114,10 @@ impl Conv for Severity { | |||
114 | } | 114 | } |
115 | } | 115 | } |
116 | 116 | ||
117 | impl ConvWith<(&LineIndex, LineEndings, &mut usize)> for CompletionItem { | 117 | impl 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 | } |