refactor: just sort completion list instead of filtering it
Also, fix sorting order of equally ranked entries.
This commit is contained in:
parent
518af3ab45
commit
b314a4c8c0
1 changed files with 6 additions and 7 deletions
|
|
@ -326,10 +326,9 @@ pub fn Create(options: type) type {
|
|||
|
||||
for (self.entries.items) |*entry| {
|
||||
const match = searcher.scoreMatches(entry.label, query);
|
||||
if (match.score) |score|
|
||||
(try matches.addOne(self.allocator)).* = .{
|
||||
.entry = entry,
|
||||
.score = score,
|
||||
.score = match.score orelse 0,
|
||||
.matches = try self.allocator.dupe(usize, match.matches),
|
||||
};
|
||||
}
|
||||
|
|
@ -338,7 +337,7 @@ pub fn Create(options: type) type {
|
|||
const less_fn = struct {
|
||||
fn less_fn(_: void, lhs: Match, rhs: Match) bool {
|
||||
return if (lhs.score == rhs.score)
|
||||
lhs.entry.label.len < rhs.entry.label.len
|
||||
std.mem.order(u8, lhs.entry.sort_text, rhs.entry.sort_text) == .lt
|
||||
else
|
||||
lhs.score > rhs.score;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue