diff options
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'); |
