fix: sort by length (shortest first) for equal fuzzy matching scores in palette

This commit is contained in:
CJ van den Berg 2024-08-29 19:09:25 +02:00
parent 9d93ba5319
commit 9b80687373
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -353,7 +353,10 @@ pub fn Create(options: type) type {
const less_fn = struct { const less_fn = struct {
fn less_fn(_: void, lhs: Match, rhs: Match) bool { fn less_fn(_: void, lhs: Match, rhs: Match) bool {
return lhs.score > rhs.score; return if (lhs.score == rhs.score)
lhs.entry.name.len < rhs.entry.name.len
else
lhs.score > rhs.score;
} }
}.less_fn; }.less_fn;
std.mem.sort(Match, matches.items, {}, less_fn); std.mem.sort(Match, matches.items, {}, less_fn);