Skip to content

Commit d48763e

Browse files
committed
save
1 parent a16dbdb commit d48763e

File tree

5 files changed

+16
-4
lines changed

5 files changed

+16
-4
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ authors = ["rust-analyzer team"]
1212
[profile.dev]
1313
# Disabling debug info speeds up builds a bunch,
1414
# and we don't rely on it for debugging that much.
15-
debug = 0
15+
debug = 2
1616

1717
[profile.dev.package]
1818
# These speed up local tests.

crates/ide-completion/src/completions.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,14 @@ impl Completions {
610610
.map(|_| false)
611611
}
612612

613+
for item in self.buf.iter_mut() {
614+
if creates_self(&item) == Some(true) {
615+
item.sort_text = Some(format!("{0:08x}", 0));
616+
} else if creates_self_given_args(&item) == Some(true) {
617+
item.sort_text = Some(format!("{0:08x}", 1));
618+
}
619+
}
620+
613621
self.buf.sort_by(|a, b| {
614622
creates_self(b)
615623
.cmp(&creates_self(a))

crates/ide-completion/src/completions/dot.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,8 @@ fn foo(a: A) { a.$0() }
278278
struct A;
279279
impl A {
280280
fn foo(&self) {}
281-
fn new_1(input: u32) -> Self { A }
282-
fn new_2() -> A { A }
281+
fn new_1(input: u32) -> A { A }
282+
fn new_2() -> Self { A }
283283
}
284284
285285
fn test() {

crates/ide-completion/src/item.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ pub struct CompletionItem {
8585
/// The import data to add to completion's edits.
8686
/// (ImportPath, LastSegment)
8787
pub import_to_add: SmallVec<[(String, String); 1]>,
88+
89+
pub sort_text: Option<String>,
8890
}
8991

9092
// We use custom debug for CompletionItem to make snapshot tests more readable.
@@ -503,6 +505,7 @@ impl Builder {
503505
relevance: self.relevance,
504506
ref_match: self.ref_match,
505507
import_to_add,
508+
sort_text: None,
506509
}
507510
}
508511
pub(crate) fn lookup_by(&mut self, lookup: impl Into<SmolStr>) -> &mut Builder {

crates/rust-analyzer/src/lsp/to_proto.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ fn completion_item(
308308
lsp_item.label.push_str(label_detail.as_str());
309309
}
310310

311-
set_score(&mut lsp_item, max_relevance, item.relevance);
311+
set_score(&mut lsp_item, max_relevance, item.relevance); // TODO: copy sort_text from CompletionItem if present (+1 instance below)
312312

313313
if config.completion().enable_imports_on_the_fly {
314314
if !item.import_to_add.is_empty() {
@@ -349,6 +349,7 @@ fn completion_item(
349349
if relevance.is_relevant() && relevance.score() == max_relevance {
350350
res.preselect = Some(true);
351351
}
352+
352353
// The relevance needs to be inverted to come up with a sort score
353354
// because the client will sort ascending.
354355
let sort_score = relevance.score() ^ 0xFF_FF_FF_FF;

0 commit comments

Comments
 (0)