summaryrefslogtreecommitdiff
path: root/test/output.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-08 12:00:28 -0300
committerGabriel Schneider <[email protected]>2026-10-22 10:03:15 -0300
commit13d5613b77c62c425c3a124a34c0c2528cc6251f (patch)
treef3cbe41683ef31641ea087039db9fc3be81e141f /test/output.zig
parent046979b877f02a91cf52cc86b84c5619cb9363d3 (diff)
downloadpardes-13d5613b77c62c425c3a124a34c0c2528cc6251f.tar.gz
pardes-13d5613b77c62c425c3a124a34c0c2528cc6251f.zip
Follow Helix search registers for n/N; keep Look navigation as named builtins
Diffstat (limited to 'test/output.zig')
-rw-r--r--test/output.zig65
1 files changed, 35 insertions, 30 deletions
diff --git a/test/output.zig b/test/output.zig
index 51d620c0..6ea6f6fa 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;
@@ -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);
}
@@ -1661,7 +1661,7 @@ test "stacked search and LSP results retain source tint navigation and dump owne
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);
}
@@ -1833,3 +1833,8 @@ test "location cache eviction retains early colors and honors disk and unsaved r
try std.testing.expectEqual(@intFromEnum(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 } });
+}