File tree Expand file tree Collapse file tree 2 files changed +10
-10
lines changed Expand file tree Collapse file tree 2 files changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -156,7 +156,7 @@ impl CompletionRelevance {
156
156
///
157
157
/// See is_relevant if you need to make some judgement about score
158
158
/// in an absolute sense.
159
- pub fn score ( & self ) -> u8 {
159
+ pub fn score ( & self ) -> u32 {
160
160
let mut score = 0 ;
161
161
162
162
if self . exact_name_match {
@@ -525,7 +525,7 @@ mod tests {
525
525
. map ( |r| ( r. score ( ) , r) )
526
526
. sorted_by_key ( |( score, _r) | * score)
527
527
. fold (
528
- ( u8 :: MIN , vec ! [ vec![ ] ] ) ,
528
+ ( u32 :: MIN , vec ! [ vec![ ] ] ) ,
529
529
|( mut currently_collecting_score, mut out) , ( score, r) | {
530
530
if currently_collecting_score == score {
531
531
out. last_mut ( ) . unwrap ( ) . push ( r) ;
Original file line number Diff line number Diff line change @@ -220,12 +220,12 @@ pub(crate) fn completion_item(
220
220
}
221
221
// The relevance needs to be inverted to come up with a sort score
222
222
// because the client will sort ascending.
223
- let sort_score = relevance. score ( ) ^ 0xFF ;
224
- // Zero pad the string to ensure values are sorted numerically
225
- // even though the client is sorting alphabetically. Three
226
- // characters is enough to fit the largest u8 , which is the
227
- // type of the relevance score.
228
- res. sort_text = Some ( format ! ( "{:03 }" , sort_score) ) ;
223
+ let sort_score = relevance. score ( ) ^ 0xFF_FF_FF_FF ;
224
+ // Zero pad the string to ensure values can be properly sorted
225
+ // by the client. Hex format is used because it is easier to
226
+ // visually compare very large values , which the sort text
227
+ // tends to be since it is the opposite of the score.
228
+ res. sort_text = Some ( format ! ( "{:08x }" , sort_score) ) ;
229
229
}
230
230
231
231
set_score ( & mut lsp_item, item. relevance ( ) ) ;
@@ -1117,13 +1117,13 @@ mod tests {
1117
1117
(
1118
1118
"&arg",
1119
1119
Some(
1120
- "253 ",
1120
+ "fffffffd ",
1121
1121
),
1122
1122
),
1123
1123
(
1124
1124
"arg",
1125
1125
Some(
1126
- "254 ",
1126
+ "fffffffe ",
1127
1127
),
1128
1128
),
1129
1129
]
You can’t perform that action at this time.
0 commit comments