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.
This commit is contained in:
Aleksey Kladov 2020-04-24 01:52:26 +02:00
parent 647683b9bb
commit 88d243c742
2 changed files with 10 additions and 18 deletions

View File

@ -9,10 +9,10 @@ use lsp_types::{
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 @@ impl Conv for Severity {
}
}
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 @@ impl ConvWith<(&LineIndex, LineEndings, &mut usize)> for CompletionItem {
..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() {

View 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()))
}