Skip to content

Commit 88d243c

Browse files
committed
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.
1 parent 647683b commit 88d243c

File tree

2 files changed

+10
-18
lines changed

2 files changed

+10
-18
lines changed

crates/rust-analyzer/src/conv.rs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ use lsp_types::{
99
TextDocumentPositionParams, Url, VersionedTextDocumentIdentifier, WorkspaceEdit,
1010
};
1111
use ra_ide::{
12-
translate_offset_with_edit, CompletionItem, CompletionItemKind, CompletionScore, FileId,
13-
FilePosition, FileRange, FileSystemEdit, Fold, FoldKind, Highlight, HighlightModifier,
14-
HighlightTag, InlayHint, InlayKind, InsertTextFormat, LineCol, LineIndex, NavigationTarget,
15-
RangeInfo, ReferenceAccess, Severity, SourceChange, SourceFileEdit,
12+
translate_offset_with_edit, CompletionItem, CompletionItemKind, FileId, FilePosition,
13+
FileRange, FileSystemEdit, Fold, FoldKind, Highlight, HighlightModifier, HighlightTag,
14+
InlayHint, InlayKind, InsertTextFormat, LineCol, LineIndex, NavigationTarget, RangeInfo,
15+
ReferenceAccess, Severity, SourceChange, SourceFileEdit,
1616
};
1717
use ra_syntax::{SyntaxKind, TextRange, TextUnit};
1818
use ra_text_edit::{AtomTextEdit, TextEdit};
@@ -114,10 +114,10 @@ impl Conv for Severity {
114114
}
115115
}
116116

117-
impl ConvWith<(&LineIndex, LineEndings, &mut usize)> for CompletionItem {
117+
impl ConvWith<(&LineIndex, LineEndings)> for CompletionItem {
118118
type Output = ::lsp_types::CompletionItem;
119119

120-
fn conv_with(self, ctx: (&LineIndex, LineEndings, &mut usize)) -> ::lsp_types::CompletionItem {
120+
fn conv_with(self, ctx: (&LineIndex, LineEndings)) -> ::lsp_types::CompletionItem {
121121
let mut additional_text_edits = Vec::new();
122122
let mut text_edit = None;
123123
// 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 {
165165
..Default::default()
166166
};
167167

168-
if let Some(score) = self.score() {
169-
match score {
170-
CompletionScore::TypeAndNameMatch => res.preselect = Some(true),
171-
CompletionScore::TypeMatch => {}
172-
}
173-
res.sort_text = Some(format!("{:02}", *ctx.2));
174-
*ctx.2 += 1;
168+
if self.score().is_some() {
169+
res.preselect = Some(true)
175170
}
176171

177172
if self.deprecated() {

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -423,11 +423,8 @@ pub fn handle_completion(
423423
};
424424
let line_index = world.analysis().file_line_index(position.file_id)?;
425425
let line_endings = world.file_line_endings(position.file_id);
426-
let mut count_sort_text_item = 0usize;
427-
let items: Vec<CompletionItem> = items
428-
.into_iter()
429-
.map(|item| item.conv_with((&line_index, line_endings, &mut count_sort_text_item)))
430-
.collect();
426+
let items: Vec<CompletionItem> =
427+
items.into_iter().map(|item| item.conv_with((&line_index, line_endings))).collect();
431428

432429
Ok(Some(items.into()))
433430
}

0 commit comments

Comments
 (0)