aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/rust-analyzer/src/conv.rs7
-rw-r--r--crates/rust-analyzer/src/main_loop/handlers.rs4
2 files changed, 6 insertions, 5 deletions
diff --git a/crates/rust-analyzer/src/conv.rs b/crates/rust-analyzer/src/conv.rs
index d0218dcbf..7e30956cc 100644
--- a/crates/rust-analyzer/src/conv.rs
+++ b/crates/rust-analyzer/src/conv.rs
@@ -114,10 +114,10 @@ impl Conv for Severity {
114 } 114 }
115} 115}
116 116
117impl ConvWith<(&LineIndex, LineEndings, usize)> for CompletionItem { 117impl ConvWith<(&LineIndex, LineEndings, &mut usize)> for CompletionItem {
118 type Output = ::lsp_types::CompletionItem; 118 type Output = ::lsp_types::CompletionItem;
119 119
120 fn conv_with(self, ctx: (&LineIndex, LineEndings, usize)) -> ::lsp_types::CompletionItem { 120 fn conv_with(self, ctx: (&LineIndex, LineEndings, &mut usize)) -> ::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
@@ -170,7 +170,8 @@ impl ConvWith<(&LineIndex, LineEndings, usize)> for CompletionItem {
170 CompletionScore::TypeAndNameMatch => res.preselect = Some(true), 170 CompletionScore::TypeAndNameMatch => res.preselect = Some(true),
171 CompletionScore::TypeMatch => {} 171 CompletionScore::TypeMatch => {}
172 } 172 }
173 res.sort_text = Some(format!("{:02}", ctx.2)); 173 res.sort_text = Some(format!("{:02}", *ctx.2));
174 *ctx.2 += 1;
174 } 175 }
175 176
176 if self.deprecated() { 177 if self.deprecated() {
diff --git a/crates/rust-analyzer/src/main_loop/handlers.rs b/crates/rust-analyzer/src/main_loop/handlers.rs
index d18d2de34..08f5ad47c 100644
--- a/crates/rust-analyzer/src/main_loop/handlers.rs
+++ b/crates/rust-analyzer/src/main_loop/handlers.rs
@@ -423,10 +423,10 @@ 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> = items 427 let items: Vec<CompletionItem> = items
427 .into_iter() 428 .into_iter()
428 .enumerate() 429 .map(|item| item.conv_with((&line_index, line_endings, &mut count_sort_text_item)))
429 .map(|(idx, item)| item.conv_with((&line_index, line_endings, idx)))
430 .collect(); 430 .collect();
431 431
432 Ok(Some(items.into())) 432 Ok(Some(items.into()))