From 12cf44acc4edede7f20440be5ac4fd81a8c7a8c0 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 1 Oct 2026 08:15:56 -0300 Subject: Find's notes stay at the end, under the names it found, as Grep's do: `1 directory skipped` no longer sorts first Find's rows are sorted by path as they are filled in, and the note line was sorted with them, so it led the list. The rows above the first note are sorted, the notes left where they are. Co-Authored-By: Claude Opus 5.5 --- src/Output.zig | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/Output.zig') diff --git a/src/Output.zig b/src/Output.zig index fc300e8b..5422411f 100644 --- a/src/Output.zig +++ b/src/Output.zig @@ -363,6 +363,15 @@ fn sortResults(arena: std.mem.Allocator, from: Origin, content: []u8, anchor: ?u } if (content.len == 0) return anchor; const path_only = std.meta.eql(from, Origin{ .cmd = .Find }); + // A walk's notes (fs.WalkNotes) stay under the hits: only the rows + // above the first are sorted. + if (path_only) { + var off: usize = 0; + var it = std.mem.splitScalar(u8, content, '\n'); + while (it.next()) |line| : (off += line.len + 1) if (@import("fs.zig").WalkNotes.isNote(line)) { + return if (off == 0) anchor else sortResults(arena, from, content[0..off], anchor); + }; + } const trailing_newline = content[content.len - 1] == '\n'; const body = content[0 .. content.len - @intFromBool(trailing_newline)]; var lines = std.mem.splitScalar(u8, body, '\n'); -- cgit v1.3