summaryrefslogtreecommitdiff
path: root/test/output.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-22 09:50:43 -0300
committerGabriel Schneider <[email protected]>2026-10-22 10:03:24 -0300
commita8b457a306a4442975210bcac3f04b56513c61c3 (patch)
tree6e2026ecb15da2fb919a0202f5d8b38e3b36a595 /test/output.zig
parenta8a1499bdffffc5b6919e24ec957e92fabaf003b (diff)
parent7e9d2c4169245072265b483ffaa6aa05f23f08d3 (diff)
downloadpardes-a8b457a306a4442975210bcac3f04b56513c61c3.tar.gz
pardes-a8b457a306a4442975210bcac3f04b56513c61c3.zip
Merge: Def/Refs, the diff viewer, Helix n/N, Callstack, Zig 0.17, Window mode and the terminal cwd fix onto 0.24
The docs keep both sides: 0.24's Ctrl-i fallbacks and typed ls with this line's Window mode, raw Esc and Helix n/N wording. The CHANGELOG's unreleased entries go above 0.24, Def/Refs and the context rows among them. cheatsheet-a4.pdf rendered again; .scratch/ ignored. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'test/output.zig')
-rw-r--r--test/output.zig75
1 files changed, 40 insertions, 35 deletions
diff --git a/test/output.zig b/test/output.zig
index 51d620c0..8403effa 100644
--- a/test/output.zig
+++ b/test/output.zig
@@ -219,11 +219,11 @@ test "reference Look selects the next sorted row from the captured request and k
try std.testing.expectEqual(results.serial, p.look_walk_owner.?);
try std.testing.expectEqual(@as(i32, 3), results.look_at.?.row);
const available = p.freeSlot();
- p.update(.{ .key = .{ .cp = 'n' } });
+ lookKey(p, 'n');
try std.testing.expectEqual(rid, p.active);
try std.testing.expectEqual(@as(i32, 4), results.body.cur_row);
try std.testing.expectEqual(available, p.freeSlot());
- p.update(.{ .key = .{ .cp = 'N' } });
+ lookKey(p, 'N');
try std.testing.expectEqual(@as(i32, 3), results.body.cur_row);
p.active = 0;
@@ -475,7 +475,7 @@ test "Mini syntax colors survive toggles themes and rendering without source acc
try panes.mini.open(p, 0, "demo.zig");
const id = p.active;
const mini = p.panes[id].?;
- const keyword = std.mem.indexOfScalar(u8, mini.file.?.mini.?.colors, @intFromEnum(pardes.syntax.Syn.keyword)) orelse return error.MissingKeywordColor;
+ const keyword = std.mem.indexOfScalar(u8, mini.file.?.mini.?.colors, @backingInt(pardes.syntax.Syn.keyword)) orelse return error.MissingKeywordColor;
// Direct pane construction bypasses the host update's layout sync.
p.update(.{ .resize = .{ .cols = 80, .rows = 24 } });
const position = modal.positionAt(mini.file.?.content, keyword);
@@ -791,7 +791,7 @@ fn selectedOutputText(pane: *const pardes.Pane) ?[]const u8 {
return line[lo..@min(line.len, hi + 1)];
}
-test "n/N in ordinary text skips comment slashes and retains real paths" {
+test "LookNext/LookPrev in ordinary text skips comment slashes and retains real paths" {
if (platform == .web) return error.SkipZigTest;
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 20 });
defer p.deinit();
@@ -808,7 +808,7 @@ test "n/N in ordinary text skips comment slashes and retains real paths" {
.{ .key = 'N', .row = 4, .text = "/tmp" },
.{ .key = 'N', .row = 3, .text = "/" },
}) |step| {
- p.update(.{ .key = .{ .cp = step.key } });
+ lookKey(p, step.key);
try std.testing.expectEqual(@as(usize, 0), p.active);
try std.testing.expectEqual(step.row, pane.body.cur_row);
try std.testing.expectEqualStrings(step.text, selectedOutputText(pane) orelse "");
@@ -816,7 +816,7 @@ test "n/N in ordinary text skips comment slashes and retains real paths" {
}
}
-test "n/N skips formatted context and selects comment match locations" {
+test "LookNext/LookPrev skips formatted context and selects comment match locations" {
if (!pardes.syntax.enabled) return error.SkipZigTest;
for ([_]panes.Output.Origin{ .search, .{ .query = .references } }) |origin| {
for ([_]bool{ false, true }) |tslocations| {
@@ -860,7 +860,7 @@ test "n/N skips formatted context and selects comment match locations" {
.{ .key = 'N', .match = 1 },
.{ .key = 'N', .match = 0 },
}) |step| {
- p.update(.{ .key = .{ .cp = step.key } });
+ lookKey(p, step.key);
try std.testing.expectEqual(id, p.active);
const row = matches[step.match];
try std.testing.expectEqual(@as(i32, @intCast(row)), result.body.cur_row);
@@ -876,9 +876,9 @@ test "n/N skips formatted context and selects comment match locations" {
// The dot came back on the match it was on (the first), so the
// walk goes on from there.
try std.testing.expectEqual(@as(i32, @intCast(matches[0])), restored_result.body.cur_row);
- restored.update(.{ .key = .{ .cp = 'n' } });
+ lookKey(restored, 'n');
try std.testing.expectEqual(@as(i32, @intCast(matches[1])), restored_result.body.cur_row);
- restored.update(.{ .key = .{ .cp = 'N' } });
+ lookKey(restored, 'N');
try std.testing.expectEqual(@as(i32, @intCast(matches[0])), restored_result.body.cur_row);
const restored_file = &restored_result.file.?;
const last = modal.lineSlice(restored_file.content, matches[0]);
@@ -887,7 +887,7 @@ test "n/N skips formatted context and selects comment match locations" {
}
}
-test "n/N selects one output location per row and opens nothing" {
+test "LookNext/LookPrev selects one output location per row and opens nothing" {
if (platform == .web) return;
var cwd_buf: [4096]u8 = undefined;
var path_buf: [4096]u8 = undefined;
@@ -900,20 +900,20 @@ test "n/N selects one output location per row and opens nothing" {
const results = p.panes[rid].?;
const panes_before = p.freeSlot();
- p.update(.{ .key = .{ .cp = 'n' } });
+ lookKey(p, 'n');
try std.testing.expectEqual(rid, p.active);
try std.testing.expectEqual(panes_before, p.freeSlot());
try std.testing.expect(results.body.vsel.active and results.body.vsel.explicit);
try std.testing.expectEqualStrings("build.zig:1:1", selectedOutputText(results) orelse "");
try std.testing.expectEqual(panes.Output.Grain.line, panes.Output.grain(results.file.?.output));
- p.update(.{ .key = .{ .cp = 'n' } });
+ lookKey(p, 'n');
try std.testing.expectEqual(@as(i32, 1), results.body.cur_row);
try std.testing.expectEqualStrings("mise.toml", selectedOutputText(results) orelse "");
- p.update(.{ .key = .{ .cp = 'n' } });
+ lookKey(p, 'n');
try std.testing.expectEqual(@as(i32, 3), results.body.cur_row); // row 2 is not look-able
try std.testing.expectEqualStrings("uucode_config.zig:7:1", selectedOutputText(results) orelse "");
- p.update(.{ .key = .{ .cp = 'n' } });
+ lookKey(p, 'n');
try std.testing.expectEqual(@as(i32, 0), results.body.cur_row); // ring seam
p.update(.{ .key = .{ .cp = Key.enter } });
@@ -922,7 +922,7 @@ test "n/N selects one output location per row and opens nothing" {
try std.testing.expectEqual(panes.Output.Grain.word, panes.Output.grain(p.panes[p.active].?.file.?.output));
}
-test "n/N resumes the result output whose Look moved focus away" {
+test "LookNext/LookPrev resumes the result output whose Look moved focus away" {
if (platform == .web) return;
var tmp = std.testing.tmpDir(.{});
defer tmp.cleanup();
@@ -945,10 +945,10 @@ test "n/N resumes the result output whose Look moved focus away" {
try std.testing.expect(results.look_at != null);
try std.testing.expectEqual(results.serial, p.look_walk_owner orelse return error.MissingLookOwner);
- p.update(.{ .key = .{ .cp = 'n' } });
+ lookKey(p, 'n');
try std.testing.expectEqual(rid, p.active);
try std.testing.expectEqual(first + 1, results.body.cur_row);
- p.update(.{ .key = .{ .cp = 'N' } });
+ lookKey(p, 'N');
try std.testing.expectEqual(first, results.body.cur_row);
// A later no-match answer has no position to resume and therefore cannot
@@ -965,7 +965,7 @@ test "n/N resumes the result output whose Look moved focus away" {
null,
);
try std.testing.expectEqual(owner, p.look_walk_owner.?);
- p.update(.{ .key = .{ .cp = 'n' } });
+ lookKey(p, 'n');
try std.testing.expectEqual(rid, p.active);
try std.testing.expectEqual(first + 1, results.body.cur_row);
@@ -981,7 +981,7 @@ test "n/N resumes the result output whose Look moved focus away" {
try std.testing.expect(p.paneBySerial(owner) == null);
}
-test "N exactly reverses n across output panes and the ring seam" {
+test "LookPrev exactly reverses LookNext across output panes and the ring seam" {
if (platform == .web) return;
var cwd_buf: [4096]u8 = undefined;
var path_buf: [4096]u8 = undefined;
@@ -1002,17 +1002,17 @@ test "N exactly reverses n across output panes and the ring seam" {
return .{ .pane = pp.active, .row = pane.body.cur_row, .col = pane.body.cur_col };
}
}.at;
- p.update(.{ .key = .{ .cp = 'n' } });
+ lookKey(p, 'n');
const base = here(p);
var trail: [12]Mark = undefined;
for (&trail) |*mark| {
- p.update(.{ .key = .{ .cp = 'n' } });
+ lookKey(p, 'n');
mark.* = here(p);
}
var i = trail.len;
while (i > 0) {
i -= 1;
- p.update(.{ .key = .{ .cp = 'N' } });
+ lookKey(p, 'N');
const want = if (i == 0) base else trail[i - 1];
try std.testing.expectEqual(want, here(p));
}
@@ -1068,20 +1068,20 @@ test "Themes lists the ring in sections and skips headings in both directions" {
// Opening an imported theme's selector must still begin with the natives.
// Walk across the section break without selecting or executing a heading.
for (pardes.themes[0 .. brk + 1]) |theme| {
- p.update(.{ .key = .{ .cp = 'n' } });
+ lookKey(p, 'n');
try std.testing.expectEqual(tid, p.active);
const selected = selectedOutputText(list) orelse return error.MissingThemeSection;
try std.testing.expectEqualStrings(theme.name, selected["Theme ".len..]);
try std.testing.expectEqual(original_theme, p.settings.theme);
}
- p.update(.{ .key = .{ .cp = 'N' } });
+ lookKey(p, 'N');
const previous = selectedOutputText(list) orelse return error.MissingThemeSection;
try std.testing.expectEqualStrings(pardes.themes[brk - 1].name, previous["Theme ".len..]);
p.update(.{ .key = .{ .cp = Key.tab } });
try std.testing.expectEqual(brk - 1, p.settings.theme);
}
-test "n/N selects command outputs by whole row" {
+test "LookNext/LookPrev selects command outputs by whole row" {
if (platform == .web) return;
var cwd_buf: [4096]u8 = undefined;
var path_buf: [4096]u8 = undefined;
@@ -1094,18 +1094,18 @@ test "n/N selects command outputs by whole row" {
const tid = p.panes[p.active].?.search_pane orelse return error.MissingThemeList;
const themes = p.panes[tid].?;
try std.testing.expect(panes.Output.fileTraits(themes.file.?.output).commands);
- p.update(.{ .key = .{ .cp = 'n' } });
+ lookKey(p, 'n');
const row0 = std.mem.trimEnd(u8, modal.lineSlice(themes.file.?.content, 1), " \t\r");
try std.testing.expectEqualStrings(row0, selectedOutputText(themes) orelse "");
const theme_before = p.settings.theme;
- p.update(.{ .key = .{ .cp = 'n' } });
+ lookKey(p, 'n');
p.update(.{ .key = .{ .cp = Key.tab } });
try std.testing.expect(p.settings.theme != theme_before);
try std.testing.expect(p.executeBuiltinLine(0, "Look build.zig"));
p.update(.tick);
try std.testing.expect(p.active != 0);
- p.update(.{ .key = .{ .cp = 'n' } });
+ lookKey(p, 'n');
try std.testing.expectEqual(@as(usize, 0), p.active);
}
@@ -1656,12 +1656,12 @@ test "stacked search and LSP results retain source tint navigation and dump owne
}
try std.testing.expectEqual(@as(usize, 6), marked);
const number = std.mem.indexOf(u8, file.content, "42").?;
- try std.testing.expectEqual(@intFromEnum(pardes.syntax.Syn.number), file.highlights[number]);
+ try std.testing.expectEqual(@backingInt(pardes.syntax.Syn.number), file.highlights[number]);
p.active = id;
pane.body.mode = .normal;
pardes.look.armLookWalk(p, id);
for ([_]struct { key: u21, match: usize }{ .{ .key = 'n', .match = 0 }, .{ .key = 'n', .match = 1 }, .{ .key = 'N', .match = 0 } }) |step| {
- p.update(.{ .key = .{ .cp = step.key } });
+ lookKey(p, step.key);
try std.testing.expectEqual(@as(i32, @intCast(matches[step.match])), pane.body.cur_row);
const row = file.location_rows[matches[step.match]];
const line = modal.lineSlice(file.content, matches[step.match]);
@@ -1686,9 +1686,9 @@ test "stacked search and LSP results retain source tint navigation and dump owne
// The dot came back on the match it was on; the walk goes on
// from it both ways, N wrapping to the last as it does live.
try std.testing.expectEqual(@as(i32, @intCast(matches[0])), restored.panes[id].?.body.cur_row);
- restored.update(.{ .key = .{ .cp = 'N' } });
+ lookKey(restored, 'N');
try std.testing.expectEqual(@as(i32, @intCast(matches[1])), restored.panes[id].?.body.cur_row);
- restored.update(.{ .key = .{ .cp = 'n' } });
+ lookKey(restored, 'n');
try std.testing.expectEqual(@as(i32, @intCast(matches[0])), restored.panes[id].?.body.cur_row);
try std.testing.expectEqualStrings(source_text, source.file.?.content);
}
@@ -1815,7 +1815,7 @@ test "location cache eviction retains early colors and honors disk and unsaved r
return error.MissingEarlyContext;
}
};
- try std.testing.expectEqual(@intFromEnum(pardes.syntax.Syn.comment), try Color.valueColor(file));
+ try std.testing.expectEqual(@backingInt(pardes.syntax.Syn.comment), try Color.valueColor(file));
const single = "f00.c:4:1-6 needle();\n";
// Put the evicted file back before a same-size edit tests exact-byte keys.
try panes.Output.fillResults(p, 0, dir, .search, "eviction", try p.gpa.dupe(u8, single), null);
@@ -1823,13 +1823,18 @@ test "location cache eviction retains early colors and honors disk and unsaved r
try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "f00.c", .data = code });
try panes.Output.fillResults(p, 0, dir, .search, "eviction", try p.gpa.dupe(u8, single), null);
try std.testing.expect(p.locations_cache.analyses > analyses);
- try std.testing.expectEqual(@intFromEnum(pardes.syntax.Syn.number), try Color.valueColor(file));
+ try std.testing.expectEqual(@backingInt(pardes.syntax.Syn.number), try Color.valueColor(file));
// An open buffer has priority over that disk revision, even with equal size.
p.gpa.free(source.file.?.path);
source.file.?.path = try std.fs.path.join(p.gpa, &.{ dir, "f00.c" });
panes.File.setContent(p, &source.file.?, try p.gpa.dupe(u8, comment));
try panes.Output.fillResults(p, 0, dir, .search, "eviction", try p.gpa.dupe(u8, single), null);
- try std.testing.expectEqual(@intFromEnum(pardes.syntax.Syn.comment), try Color.valueColor(file));
+ try std.testing.expectEqual(@backingInt(pardes.syntax.Syn.comment), try Color.valueColor(file));
try std.testing.expectEqualStrings(comment, source.file.?.content);
}
+
+fn lookKey(p: *Pardes, key: u21) void {
+ for ([_]u21{ ' ', 'j', if (key == 'N') 'p' else 'n' }) |cp|
+ p.update(.{ .key = .{ .cp = cp } });
+}