File tree Expand file tree Collapse file tree 5 files changed +16
-4
lines changed Expand file tree Collapse file tree 5 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ authors = ["rust-analyzer team"]
12
12
[profile .dev ]
13
13
# Disabling debug info speeds up builds a bunch,
14
14
# and we don't rely on it for debugging that much.
15
- debug = 0
15
+ debug = 2
16
16
17
17
[profile .dev .package ]
18
18
# These speed up local tests.
Original file line number Diff line number Diff line change @@ -610,6 +610,14 @@ impl Completions {
610
610
. map ( |_| false )
611
611
}
612
612
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
+
613
621
self . buf . sort_by ( |a, b| {
614
622
creates_self ( b)
615
623
. cmp ( & creates_self ( a) )
Original file line number Diff line number Diff line change @@ -278,8 +278,8 @@ fn foo(a: A) { a.$0() }
278
278
struct A;
279
279
impl A {
280
280
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 }
283
283
}
284
284
285
285
fn test() {
Original file line number Diff line number Diff line change @@ -85,6 +85,8 @@ pub struct CompletionItem {
85
85
/// The import data to add to completion's edits.
86
86
/// (ImportPath, LastSegment)
87
87
pub import_to_add : SmallVec < [ ( String , String ) ; 1 ] > ,
88
+
89
+ pub sort_text : Option < String > ,
88
90
}
89
91
90
92
// We use custom debug for CompletionItem to make snapshot tests more readable.
@@ -503,6 +505,7 @@ impl Builder {
503
505
relevance : self . relevance ,
504
506
ref_match : self . ref_match ,
505
507
import_to_add,
508
+ sort_text : None ,
506
509
}
507
510
}
508
511
pub ( crate ) fn lookup_by ( & mut self , lookup : impl Into < SmolStr > ) -> & mut Builder {
Original file line number Diff line number Diff line change @@ -308,7 +308,7 @@ fn completion_item(
308
308
lsp_item. label . push_str ( label_detail. as_str ( ) ) ;
309
309
}
310
310
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)
312
312
313
313
if config. completion ( ) . enable_imports_on_the_fly {
314
314
if !item. import_to_add . is_empty ( ) {
@@ -349,6 +349,7 @@ fn completion_item(
349
349
if relevance. is_relevant ( ) && relevance. score ( ) == max_relevance {
350
350
res. preselect = Some ( true ) ;
351
351
}
352
+
352
353
// The relevance needs to be inverted to come up with a sort score
353
354
// because the client will sort ascending.
354
355
let sort_score = relevance. score ( ) ^ 0xFF_FF_FF_FF ;
You can’t perform that action at this time.
0 commit comments