summaryrefslogtreecommitdiff
path: root/test/panes.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-05 10:48:36 -0300
committerGabriel Schneider <[email protected]>2026-11-05 10:57:08 -0300
commitfc02325789b5a6622f9e577c9a45e65806c516b6 (patch)
tree65fdeed6959aef6afe0db5d18df3649aef0d2a34 /test/panes.zig
parent856bf4a8ed36cc6ec38dc9001f753a8838106da2 (diff)
downloadpardes-fc02325789b5a6622f9e577c9a45e65806c516b6.tar.gz
pardes-fc02325789b5a6622f9e577c9a45e65806c516b6.zip
Callstack a plain tree with a depth: CallstackLayout and CallstackCorners go with the inline layout and the square corners (each snippet below its location, the corners rounded, as both defaulted to), and the 100,000-row paging goes: a tree bigger than one answer holds stops there, its last row saying so as at the memory limit, and Callstack run in +Callstack asks nothing (only a file's pane asks a language server) where it showed the next page (lsp.callstack_more, the core's callstack_more, callstackMore and lspRequestAt, the walk's start and cut paths); CallstackDepth stays, as the reference documents it and the user's init sets it; treePrefix reads only the glyphs the tree draws, and the tests that fed it others take the drawn ones; callstack-inline.snap goes with its layout and callstack.snap snaps its style in its stead (its golden gains that section, the text byte-identical); the reference, the guide, the changelog's entry and both builtins lists say so
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'test/panes.zig')
-rw-r--r--test/panes.zig30
1 files changed, 13 insertions, 17 deletions
diff --git a/test/panes.zig b/test/panes.zig
index b02cf296..011399f5 100644
--- a/test/panes.zig
+++ b/test/panes.zig
@@ -1777,14 +1777,13 @@ const OutputTests = struct {
}
}
- test "stacked Callstack aligns source below locations and keeps exact emphasis and navigation" {
+ test "Callstack aligns source below locations and keeps exact emphasis and navigation" {
if (!syntax.enabled) return error.SkipZigTest;
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 30 });
defer p.deinit();
const source = " pub fn caller(\n value: u32,\n ) void {\n work(value);\n }\n";
const pane = try TreeContextTests.setZigFile(p, source);
- try std.testing.expectEqual(config.Runtime.CallstackLayout.stacked, p.settings.callstack_layout);
- const input = try std.fmt.allocPrint(p.gpa, "╰──╮ {s}:1:12-17 caller\n@callstack-match ╰─ {s}:4:9-12 work(value);\n", .{ pane.file.?.path, pane.file.?.path });
+ const input = try std.fmt.allocPrint(p.gpa, "╰──┬ {s}:1:12-17 caller\n@callstack-match ╰─ {s}:4:9-12 work(value);\n", .{ pane.file.?.path, pane.file.?.path });
try fillResults(p, 0, "/", .{ .query = .callstack }, "", input, null);
const result_id = pane.search_pane.?;
const result = p.panes[result_id].?;
@@ -1806,29 +1805,24 @@ const OutputTests = struct {
}
p.active = result_id;
result.body.cur_row = 4;
- result.body.cur_col = " └─ ".len;
+ result.body.cur_col = " ╰─ ".len;
p.update(.{ .key = .{ .cp = Key.enter } });
try std.testing.expectEqual(@as(usize, 0), p.active);
try std.testing.expectEqual(@as(i32, 3), pane.body.cur_row);
try pardes.dump.dumpState(p);
const restored = try pardes.dump.initFromDump(p.gpa, .{ .tty_only = true }, p.dump_out.?);
defer restored.deinit();
- try std.testing.expectEqual(config.Runtime.CallstackLayout.stacked, restored.settings.callstack_layout);
const after = restored.panes[result_id].?.file.?;
try std.testing.expectEqualStrings(file.content, after.content);
try std.testing.expectEqual(@as(usize, 8), after.location_rows[5].source_column);
const restored_decoration = panes.Output.decorateRow(after.output, text, after.location_rows[5]);
try std.testing.expectEqual(decoration, restored_decoration);
- try std.testing.expect(p.executeBuiltinLine(0, "CallstackLayout inline"));
- try fillResults(p, 0, "/", .{ .query = .callstack }, "", try p.gpa.dupe(u8, "No callers reported\n"), null);
- try std.testing.expectEqual(config.Runtime.CallstackLayout.@"inline", p.settings.callstack_layout);
}
test "Callstack signatures share unsaved tree context and keep guides out of Look selections" {
if (!syntax.enabled) return error.SkipZigTest;
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 110, .rows = 30 });
defer p.deinit();
- p.settings.callstack_layout = .@"inline";
const source = "const Box = struct {\n" ++
" pub fn caller(\n" ++
" value: u32,\n" ++
@@ -1837,7 +1831,7 @@ const OutputTests = struct {
" }\n};\n";
const pane = try TreeContextTests.setZigFile(p, source);
const path = pane.file.?.path;
- const input = try std.fmt.allocPrint(p.gpa, "├──┬ {s}:2:12-17 caller\n@callstack-match │ └─ {s}:5:9-12 work(value);\n└─── missing.zig:3:4-8 other ↻ recursion\n", .{ path, path });
+ const input = try std.fmt.allocPrint(p.gpa, "├──┬ {s}:2:12-17 caller\n@callstack-match │ ╰─ {s}:5:9-12 work(value);\n╰─── missing.zig:3:4-8 other ↻ recursion\n", .{ path, path });
try fillResults(p, 0, "/", .{ .query = .callstack }, "", input, null);
const result_id = pane.search_pane.?;
const result = p.panes[result_id].?;
@@ -1846,20 +1840,22 @@ const OutputTests = struct {
try std.testing.expect(std.mem.indexOf(u8, file.content, "value: u32,") != null);
try std.testing.expect(std.mem.indexOf(u8, file.content, "const Box") == null);
try std.testing.expect(std.mem.indexOf(u8, file.content, "other ↻ recursion") != null);
- try std.testing.expectEqual(@as(usize, 5), file.location_rows.len);
- for (file.location_rows[0..3]) |row| {
+ // Each location on its row, its code below it: the caller's
+ // three-line signature, the call site's line, the missing file's text.
+ try std.testing.expectEqual(@as(usize, 8), file.location_rows.len);
+ for (file.location_rows[1..4]) |row| {
try std.testing.expect(!row.declaration);
try std.testing.expect(!row.mark_occurrence);
try std.testing.expect(row.colors.len > 0);
}
- for (1..3) |index| try std.testing.expect(std.mem.startsWith(u8, modal.lineSlice(file.content, index), "│ │ "));
+ for (1..4) |index| try std.testing.expect(std.mem.startsWith(u8, modal.lineSlice(file.content, index), "│ │ "));
const analysis = try syntax.analyzeSource(p.scratch.allocator(), path, source, true, true);
- for (file.location_rows[0..3], 1..) |row, source_row| {
- const offset = modal.lineStartOffset(source, source_row);
+ for (file.location_rows[1..4], 1..) |row, source_row| {
+ const offset = modal.lineStartOffset(source, source_row) + row.source_column;
try std.testing.expectEqualSlices(u8, analysis.colors[offset..][0..row.colors.len], row.colors);
}
- try std.testing.expect(file.location_rows[3].mark_occurrence);
- try std.testing.expect(!file.location_rows[3].declaration);
+ try std.testing.expect(file.location_rows[5].mark_occurrence);
+ try std.testing.expect(!file.location_rows[5].declaration);
try std.testing.expect(!panes.Output.isWalkRow(file, 1, modal.lineSlice(file.content, 1)));
p.active = result_id;
result.body.cur_row = 0;