diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-01 08:15:56 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 08:53:11 -0300 |
| commit | 12cf44acc4edede7f20440be5ac4fd81a8c7a8c0 (patch) | |
| tree | fa5e7434c254b446ab72fe0a4d9676420bc4fb54 /src/Output.zig | |
| parent | a274bd2c706fdfd3effa0ad88c5b4083c0dc0f33 (diff) | |
| download | pardes-12cf44acc4edede7f20440be5ac4fd81a8c7a8c0.tar.gz pardes-12cf44acc4edede7f20440be5ac4fd81a8c7a8c0.zip | |
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 <[email protected]>
Diffstat (limited to 'src/Output.zig')
| -rw-r--r-- | src/Output.zig | 9 |
1 files changed, 9 insertions, 0 deletions
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'); |
