diff options
author | Josh Mcguigan <[email protected]> | 2021-03-12 14:08:07 +0000 |
---|---|---|
committer | Josh Mcguigan <[email protected]> | 2021-03-12 14:16:04 +0000 |
commit | acbe297fbd10250e0d99d1e3e98751dd6ef77adc (patch) | |
tree | 5ff7a667e2d10a69333af496b75a85a637f0488c /crates/rust-analyzer/src/to_proto.rs | |
parent | 10fb065b146d7d03a65bbc73cdb34d32523dafa1 (diff) |
update relevance score u8 -> u32
Diffstat (limited to 'crates/rust-analyzer/src/to_proto.rs')
-rw-r--r-- | crates/rust-analyzer/src/to_proto.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs index a467bc685..1a8cdadad 100644 --- a/crates/rust-analyzer/src/to_proto.rs +++ b/crates/rust-analyzer/src/to_proto.rs | |||
@@ -220,12 +220,12 @@ pub(crate) fn completion_item( | |||
220 | } | 220 | } |
221 | // The relevance needs to be inverted to come up with a sort score | 221 | // The relevance needs to be inverted to come up with a sort score |
222 | // because the client will sort ascending. | 222 | // because the client will sort ascending. |
223 | let sort_score = relevance.score() ^ 0xFF; | 223 | let sort_score = relevance.score() ^ 0xFF_FF_FF_FF; |
224 | // Zero pad the string to ensure values are sorted numerically | 224 | // Zero pad the string to ensure values can be properly sorted |
225 | // even though the client is sorting alphabetically. Three | 225 | // by the client. Hex format is used because it is easier to |
226 | // characters is enough to fit the largest u8, which is the | 226 | // visually compare very large values, which the sort text |
227 | // type of the relevance score. | 227 | // tends to be since it is the opposite of the score. |
228 | res.sort_text = Some(format!("{:03}", sort_score)); | 228 | res.sort_text = Some(format!("{:08x}", sort_score)); |
229 | } | 229 | } |
230 | 230 | ||
231 | set_score(&mut lsp_item, item.relevance()); | 231 | set_score(&mut lsp_item, item.relevance()); |
@@ -1117,13 +1117,13 @@ mod tests { | |||
1117 | ( | 1117 | ( |
1118 | "&arg", | 1118 | "&arg", |
1119 | Some( | 1119 | Some( |
1120 | "253", | 1120 | "fffffffd", |
1121 | ), | 1121 | ), |
1122 | ), | 1122 | ), |
1123 | ( | 1123 | ( |
1124 | "arg", | 1124 | "arg", |
1125 | Some( | 1125 | Some( |
1126 | "254", | 1126 | "fffffffe", |
1127 | ), | 1127 | ), |
1128 | ), | 1128 | ), |
1129 | ] | 1129 | ] |