From b314a4c8c006317e83b23116b4a0233944cfc0bd Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Fri, 30 Jan 2026 11:22:49 +0100 Subject: [PATCH] refactor: just sort completion list instead of filtering it Also, fix sorting order of equally ranked entries. --- src/tui/mode/overlay/dropdown.zig | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/tui/mode/overlay/dropdown.zig b/src/tui/mode/overlay/dropdown.zig index d637d17..6fd7956 100644 --- a/src/tui/mode/overlay/dropdown.zig +++ b/src/tui/mode/overlay/dropdown.zig @@ -326,19 +326,18 @@ 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, - .matches = try self.allocator.dupe(usize, match.matches), - }; + (try matches.addOne(self.allocator)).* = .{ + .entry = entry, + .score = match.score orelse 0, + .matches = try self.allocator.dupe(usize, match.matches), + }; } if (matches.items.len == 0) return 0; 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; }