diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-04 23:43:45 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-04 23:48:44 -0300 |
| commit | 55492ffa53d7df11a38c6639f8fde6cdc87800c7 (patch) | |
| tree | d6515b6a0dbcac62c305c999ad5865943b4c466a /src/Output.zig | |
| parent | 5a927d1a4e92750bc0d48994df2c2e552d669b01 (diff) | |
| download | pardes-55492ffa53d7df11a38c6639f8fde6cdc87800c7.tar.gz pardes-55492ffa53d7df11a38c6639f8fde6cdc87800c7.zip | |
Find, Grep: their output traits, Output's sort of a Find's whole filenames above its walk notes, and fs.WalkNotes go, as both search on the disk engine (Stream.zig, which keeps the walk's depth as max_walk_depth) and nothing makes a .cmd = .Find or .Grep pane; the tests that filled one fill a .search or query pane (ctl.zig's is now "workspace symbols, Symbols and Diagnostics share their directory's one +Search"), and the Find sort test keeps its half on next location ("next location uses numeric columns")
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/Output.zig')
| -rw-r--r-- | src/Output.zig | 25 |
1 files changed, 4 insertions, 21 deletions
diff --git a/src/Output.zig b/src/Output.zig index 7c8b7f59..cee15dcd 100644 --- a/src/Output.zig +++ b/src/Output.zig @@ -241,8 +241,6 @@ test "plain output does not opt into location decoration" { try std.testing.expectEqualDeep(RowDecoration{}, prose); const errors = rowDecoration(.{ .from = .errors }, "src/a.rs:3:5-7 error: prose"); try std.testing.expectEqualDeep(RowDecoration{}, errors); - try std.testing.expect(!traits(.{ .cmd = .Find }).locations); - try std.testing.expect(traits(.{ .cmd = .Grep }).locations); try std.testing.expect(traits(.{ .query = .completion }).locations); } @@ -299,7 +297,6 @@ pub fn traits(o: Origin) Traits { pub fn usesLocationsConfig(from: Origin) bool { const tr = traits(from); return tr.steps and !tr.commands and from != .pdf_links and - !std.meta.eql(from, Origin{ .cmd = .Find }) and !std.meta.eql(from, Origin{ .query = .completion }) and !std.meta.eql(from, Origin{ .query = .callstack }); } @@ -353,10 +350,7 @@ pub fn isResultRow(file: *const File.State, row: usize) bool { fn sortResults(arena: std.mem.Allocator, from: Origin, content: []u8, anchor: ?usize) !?usize { switch (from) { .search => {}, - .cmd => |cmd| switch (cmd) { - .Find, .Grep => {}, - else => return anchor, - }, + .cmd => return anchor, .query => |kind| switch (kind) { .definition, .declaration, @@ -379,16 +373,6 @@ fn sortResults(arena: std.mem.Allocator, from: Origin, content: []u8, anchor: ?u .errors, .pdf_links, .unsaved, .dir, .preview => return anchor, } 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'); @@ -396,8 +380,8 @@ fn sortResults(arena: std.mem.Allocator, from: Origin, content: []u8, anchor: ?u var sorted = true; var count: usize = 0; while (lines.next()) |line| { - const current: Location = if (path_only) .{ .path = line, .at = .{}, .end = line.len } else location(line); - if (!path_only and current.at.line == 0) return anchor; + const current = location(line); + if (current.at.line == 0) return anchor; if (previous) |last| if (last.order(current) == .gt) { sorted = false; }; @@ -424,10 +408,9 @@ fn sortResults(arena: std.mem.Allocator, from: Origin, content: []u8, anchor: ?u lines = std.mem.splitScalar(u8, copy, '\n'); for (rows, 0..) |*row, original| { const text = lines.next().?; - const target: Location = if (path_only) .{ .path = text, .at = .{}, .end = text.len } else location(text); row.* = .{ .text = text, - .target = target, + .target = location(text), .original = original, }; } |
