diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-05 10:48:36 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-05 10:57:08 -0300 |
| commit | fc02325789b5a6622f9e577c9a45e65806c516b6 (patch) | |
| tree | 65fdeed6959aef6afe0db5d18df3649aef0d2a34 /test | |
| parent | 856bf4a8ed36cc6ec38dc9001f753a8838106da2 (diff) | |
| download | pardes-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')
| -rw-r--r-- | test/behaviour/callstack.zig | 14 | ||||
| -rw-r--r-- | test/panes.zig | 30 | ||||
| -rw-r--r-- | test/snapshots/callstack-inline.golden | 65 | ||||
| -rw-r--r-- | test/snapshots/callstack-inline.snap | 30 | ||||
| -rw-r--r-- | test/snapshots/callstack.golden | 41 | ||||
| -rw-r--r-- | test/snapshots/callstack.snap | 4 |
6 files changed, 71 insertions, 113 deletions
diff --git a/test/behaviour/callstack.zig b/test/behaviour/callstack.zig index 42448031..7c8b5d50 100644 --- a/test/behaviour/callstack.zig +++ b/test/behaviour/callstack.zig @@ -59,3 +59,17 @@ test "callstack: CallstackDepth bounds the walk, its last row inviting a Callsta \\ ); } + +test "callstack: Callstack run in +Callstack asks nothing, as only a file's pane asks a language server" { + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + var s = try Session.initLanguage(std.testing.allocator); + defer s.deinit(); + const main = try openMain(&s, &tmp); + try s.write(s.at("/pane/{d}/ctl", .{main}), "Callstack\n"); + const tree = try s.focused(); + const shown = try s.read(s.at("/pane/{d}/body", .{tree})); + try std.testing.expect(try s.refused(s.at("/pane/{d}/ctl", .{tree}), "Callstack\n") != 0); + try std.testing.expectEqualStrings("Callstack: only a file's pane asks a language server", s.said); + try s.expect(s.at("/pane/{d}/body", .{tree}), shown); +} 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; diff --git a/test/snapshots/callstack-inline.golden b/test/snapshots/callstack-inline.golden deleted file mode 100644 index 96b74493..00000000 --- a/test/snapshots/callstack-inline.golden +++ /dev/null @@ -1,65 +0,0 @@ -== snap hierarchy grid=110x40 cursor=7,14 -| Newcol Joincol Find Grep Help Changelog Tutor Dump Themes Config Debug Exit -| New Term Find Grep Joincol Delcol -| /tmp/pardes-snap/callstack-inline/cwd/setup.txt Save Term Collapse Del -| 1 CallstackLayout inline -| 2 main.rs -| /tmp/pardes-snap/callstack-inline/cwd/main.rs Save Term Collapse TreeContext Def Refs Del -| 1 mod lib; --:--:-- lsp rust-analyzer: ready -| 2 -| 3 fn main() { -| 4 let x = add(1, 2); -| 5 let y = add(3, 4); -| 6 let _ = x + y; -| 7 } -| /tmp/pardes-snap/callstack-inline/cwd/+Callstack Save Term Collapse Del -| 1 ╰──┬ main.rs:3:4-7 fn main() { -| 2 ├─ main.rs:4:13-15 let x = add(1, 2); -| 3 ├─ main.rs:5:13-15 let y = add(3, 4); -| 4 ╰──┬ main.rs:3:4-7 fn main() { ↻ recursion -| 5 ├─ main.rs:4:13-15 let x = add(1, 2); -| 6 ╰─ main.rs:5:13-15 let y = add(3, 4); -| 7 -== style hierarchy grid=110x40 -|0: 0-1 d,#1d2824, 2-109 #b2c3b8,#1d2824, -|1: 0-1 d,#887455, 2-109 #becfc4,#314738, -|2: 0-1 d,#496656, 2-39 #b2c3b8,#1d2824, 40-49 #d3b0d9,#1d2824, 50-109 #b2c3b8,#1d2824, -|3: 0-0 d,#608269, 1-4 d,#0d1410, 5-6 #59675c,#0d1410, 7-109 #e5eee5,#0d1410, -|4: 0-0 d,#152019, 1-4 d,#0d1410, 5-6 #59675c,#0d1410, 7-109 #e5eee5,#0d1410, -|5: 0-1 d,#496656, 2-39 #b2c3b8,#1d2824, 40-47 #d3b0d9,#1d2824, 48-109 #b2c3b8,#1d2824, -|6: 0-0 d,#608269, 1-4 d,#0d1410, 5-6 #59675c,#0d1410, 7-10 #c9a7ed,#0d1410, 11-73 #e5eee5,#0d1410, 74-74 #e5eee5,#1d2824, 75-109 #b2c3b8,#1d2824, -|7: 0-0 d,#608269, 1-4 d,#0d1410, 5-109 #59675c,#0d1410, -|8: 0-0 d,#608269, 1-4 d,#0d1410, 5-6 #59675c,#0d1410, 7-9 #c9a7ed,#0d1410, 10-109 #e5eee5,#0d1410, -|9: 0-0 d,#608269, 1-4 d,#0d1410, 5-10 #59675c,#0d1410, 11-14 #c9a7ed,#0d1410, 15-109 #e5eee5,#0d1410, -|10: 0-0 d,#608269, 1-4 d,#0d1410, 5-10 #59675c,#0d1410, 11-14 #c9a7ed,#0d1410, 15-109 #e5eee5,#0d1410, -|11: 0-0 d,#608269, 1-4 d,#0d1410, 5-10 #59675c,#0d1410, 11-14 #c9a7ed,#0d1410, 15-109 #e5eee5,#0d1410, -|12: 0-0 d,#152019, 1-4 d,#0d1410, 5-6 #59675c,#0d1410, 7-109 #e5eee5,#0d1410, -|13: 0-1 d,#add38a, 2-39 #becfc4,#314738, 40-50 #dfbce5,#314738, 51-109 #becfc4,#314738, -|14: 0-0 d,#608269, 1-1 d,#0d1410, 2-4 d,#0d1410,b 5-6 #616f64,#0d1410,b 7-11 #92d1de,#0d1410, 12-25 #59675c,#0d1410, 26-28 #c9a7ed,#0d1410, 29-109 #e5eee5,#0d1410, -|15: 0-0 d,#608269, 1-4 d,#0d1410, 5-9 #59675c,#0d1410, 10-12 #92d1de,#0d1410, 13-32 #59675c,#0d1410, 33-36 #c9a7ed,#0d1410, 37-109 #e5eee5,#0d1410, -|16: 0-0 d,#608269, 1-4 d,#0d1410, 5-9 #59675c,#0d1410, 10-12 #92d1de,#0d1410, 13-32 #59675c,#0d1410, 33-36 #c9a7ed,#0d1410, 37-109 #e5eee5,#0d1410, -|17: 0-0 d,#608269, 1-4 d,#0d1410, 5-9 #59675c,#0d1410, 10-14 #92d1de,#0d1410, 15-28 #59675c,#0d1410, 29-31 #c9a7ed,#0d1410, 32-109 #e5eee5,#0d1410, -|18: 0-0 d,#608269, 1-4 d,#0d1410, 5-12 #59675c,#0d1410, 13-15 #92d1de,#0d1410, 16-35 #59675c,#0d1410, 36-39 #c9a7ed,#0d1410, 40-43 #e5eee5,#0d1410, 44-46 #f7e4a5,#5e4923, 47-109 #e5eee5,#0d1410, -|19: 0-0 d,#608269, 1-4 d,#0d1410, 5-12 #59675c,#0d1410, 13-15 #92d1de,#0d1410, 16-35 #59675c,#0d1410, 36-39 #c9a7ed,#0d1410, 40-43 #e5eee5,#0d1410, 44-46 #f7e4a5,#5e4923, 47-109 #e5eee5,#0d1410, -|20: 0-0 d,#608269, 1-4 d,#0d1410, 5-109 #59675c,#0d1410, -|21: 0-0 d,#608269, 1-109 d,#0d1410, -|22: 0-0 d,#608269, 1-109 d,#0d1410, -|23: 0-0 d,#608269, 1-109 d,#0d1410, -|24: 0-0 d,#608269, 1-109 d,#0d1410, -|25: 0-0 d,#608269, 1-109 d,#0d1410, -|26: 0-0 d,#608269, 1-109 d,#0d1410, -|27: 0-0 d,#608269, 1-109 d,#0d1410, -|28: 0-0 d,#608269, 1-109 d,#0d1410, -|29: 0-0 d,#608269, 1-109 d,#0d1410, -|30: 0-0 d,#608269, 1-109 d,#0d1410, -|31: 0-0 d,#608269, 1-109 d,#0d1410, -|32: 0-0 d,#608269, 1-109 d,#0d1410, -|33: 0-0 d,#608269, 1-109 d,#0d1410, -|34: 0-0 d,#608269, 1-109 d,#0d1410, -|35: 0-0 d,#608269, 1-109 d,#0d1410, -|36: 0-0 d,#608269, 1-109 d,#0d1410, -|37: 0-0 d,#608269, 1-109 d,#0d1410, -|38: 0-0 d,#608269, 1-109 d,#0d1410, -|39: 0-0 d,#608269, 1-109 d,#0d1410, -== snap caller grid=110x40 cursor=13,8 -|6: 1 mod lib; diff --git a/test/snapshots/callstack-inline.snap b/test/snapshots/callstack-inline.snap deleted file mode 100644 index 9acfa206..00000000 --- a/test/snapshots/callstack-inline.snap +++ /dev/null @@ -1,30 +0,0 @@ -# Inline remains an option; source colors, rounded guides and Look navigation are retained. -file main.rs mod lib;\n\nfn main() {\n let x = add(1, 2);\n let y = add(3, 4);\n let _ = x + y;\n}\n -file lib.rs // mock fixture\npub fn add(a: i32, b: i32) -> i32 {\n a + b\n}\n -file setup.txt CallstackLayout inline\nmain.rs\n -start 40 110 setup.txt -wait 8000 CallstackLayout inline -key g g -key x -key tab -stable 300 10000 -key esc -settle 100 -key g g -key j -key home -key enter -wait 8000 add(1, 2) -stable 700 20000 -key g c -wait 10000 Callstack -wait 10000 recursion -stable 700 15000 -snap hierarchy -snapstyle hierarchy -# LookNext selects the caller signature; Enter opens it in the source pane. -key space j n -key enter -wait 10000 fn main -stable 700 15000 -snap caller diff --git a/test/snapshots/callstack.golden b/test/snapshots/callstack.golden index 482a5f83..bac5a127 100644 --- a/test/snapshots/callstack.golden +++ b/test/snapshots/callstack.golden @@ -23,5 +23,46 @@ | 11 ╰─ main.rs:5:13-15 | 12 let y = add(3, 4); | 13 +== style hierarchy grid=110x40 +|0: 0-1 d,#1d2824, 2-109 #b2c3b8,#1d2824, +|1: 0-1 d,#887455, 2-109 #becfc4,#314738, +|2: 0-1 d,#496656, 2-32 #b2c3b8,#1d2824, 33-40 #d3b0d9,#1d2824, 41-109 #b2c3b8,#1d2824, +|3: 0-0 d,#608269, 1-4 d,#0d1410, 5-6 #59675c,#0d1410, 7-10 #c9a7ed,#0d1410, 11-73 #e5eee5,#0d1410, 74-74 #e5eee5,#1d2824, 75-109 #b2c3b8,#1d2824, +|4: 0-0 d,#608269, 1-4 d,#0d1410, 5-109 #59675c,#0d1410, +|5: 0-0 d,#608269, 1-4 d,#0d1410, 5-6 #59675c,#0d1410, 7-9 #c9a7ed,#0d1410, 10-109 #e5eee5,#0d1410, +|6: 0-0 d,#608269, 1-4 d,#0d1410, 5-10 #59675c,#0d1410, 11-14 #c9a7ed,#0d1410, 15-109 #e5eee5,#0d1410, +|7: 0-0 d,#608269, 1-4 d,#0d1410, 5-10 #59675c,#0d1410, 11-14 #c9a7ed,#0d1410, 15-109 #e5eee5,#0d1410, +|8: 0-0 d,#608269, 1-4 d,#0d1410, 5-10 #59675c,#0d1410, 11-14 #c9a7ed,#0d1410, 15-109 #e5eee5,#0d1410, +|9: 0-0 d,#152019, 1-4 d,#0d1410, 5-6 #59675c,#0d1410, 7-109 #e5eee5,#0d1410, +|10: 0-1 d,#add38a, 2-32 #becfc4,#314738, 33-43 #dfbce5,#314738, 44-109 #becfc4,#314738, +|11: 0-0 d,#608269, 1-1 d,#0d1410, 2-4 d,#0d1410,b 5-6 #616f64,#0d1410,b 7-11 #92d1de,#0d1410, 12-109 #59675c,#0d1410, +|12: 0-0 d,#608269, 1-4 d,#0d1410, 5-9 #59675c,#0d1410, 10-11 #92d1de,#0d1410, 12-14 #c9a7ed,#0d1410, 15-109 #e5eee5,#0d1410, +|13: 0-0 d,#608269, 1-4 d,#0d1410, 5-9 #59675c,#0d1410, 10-12 #92d1de,#0d1410, 13-109 #59675c,#0d1410, +|14: 0-0 d,#608269, 1-4 d,#0d1410, 5-9 #59675c,#0d1410, 10-12 #92d1de,#0d1410, 13-16 #c9a7ed,#0d1410, 17-109 #e5eee5,#0d1410, +|15: 0-0 d,#608269, 1-4 d,#0d1410, 5-9 #59675c,#0d1410, 10-12 #92d1de,#0d1410, 13-109 #59675c,#0d1410, +|16: 0-0 d,#608269, 1-4 d,#0d1410, 5-9 #59675c,#0d1410, 10-12 #92d1de,#0d1410, 13-16 #c9a7ed,#0d1410, 17-109 #e5eee5,#0d1410, +|17: 0-0 d,#608269, 1-4 d,#0d1410, 5-9 #59675c,#0d1410, 10-14 #92d1de,#0d1410, 15-109 #59675c,#0d1410, +|18: 0-0 d,#608269, 1-4 d,#0d1410, 5-12 #59675c,#0d1410, 13-14 #92d1de,#0d1410, 15-17 #c9a7ed,#0d1410, 18-109 #e5eee5,#0d1410, +|19: 0-0 d,#608269, 1-4 d,#0d1410, 5-12 #59675c,#0d1410, 13-15 #92d1de,#0d1410, 16-109 #59675c,#0d1410, +|20: 0-0 d,#608269, 1-3 d,#0d1410, 4-12 #59675c,#0d1410, 13-15 #92d1de,#0d1410, 16-19 #c9a7ed,#0d1410, 20-23 #e5eee5,#0d1410, 24-26 #f7e4a5,#5e4923, 27-109 #e5eee5,#0d1410, +|21: 0-0 d,#608269, 1-3 d,#0d1410, 4-12 #59675c,#0d1410, 13-15 #92d1de,#0d1410, 16-109 #59675c,#0d1410, +|22: 0-0 d,#608269, 1-3 d,#0d1410, 4-15 #59675c,#0d1410, 16-19 #c9a7ed,#0d1410, 20-23 #e5eee5,#0d1410, 24-26 #f7e4a5,#5e4923, 27-109 #e5eee5,#0d1410, +|23: 0-0 d,#608269, 1-3 d,#0d1410, 4-109 #59675c,#0d1410, +|24: 0-0 d,#608269, 1-109 d,#0d1410, +|25: 0-0 d,#608269, 1-109 d,#0d1410, +|26: 0-0 d,#608269, 1-109 d,#0d1410, +|27: 0-0 d,#608269, 1-109 d,#0d1410, +|28: 0-0 d,#608269, 1-109 d,#0d1410, +|29: 0-0 d,#608269, 1-109 d,#0d1410, +|30: 0-0 d,#608269, 1-109 d,#0d1410, +|31: 0-0 d,#608269, 1-109 d,#0d1410, +|32: 0-0 d,#608269, 1-109 d,#0d1410, +|33: 0-0 d,#608269, 1-109 d,#0d1410, +|34: 0-0 d,#608269, 1-109 d,#0d1410, +|35: 0-0 d,#608269, 1-109 d,#0d1410, +|36: 0-0 d,#608269, 1-109 d,#0d1410, +|37: 0-0 d,#608269, 1-109 d,#0d1410, +|38: 0-0 d,#608269, 1-109 d,#0d1410, +|39: 0-0 d,#608269, 1-109 d,#0d1410, == snap caller grid=110x40 cursor=13,5 |3: 1 mod lib; diff --git a/test/snapshots/callstack.snap b/test/snapshots/callstack.snap index b32367af..c0adb909 100644 --- a/test/snapshots/callstack.snap +++ b/test/snapshots/callstack.snap @@ -1,4 +1,5 @@ -# Static call hierarchy in a dedicated pane; sites and declarations are Look targets. +# Static call hierarchy in a dedicated pane; sites and declarations are Look +# targets, the source's colours on them. file main.rs mod lib;\n\nfn main() {\n let x = add(1, 2);\n let y = add(3, 4);\n let _ = x + y;\n}\n file lib.rs // mock fixture\npub fn add(a: i32, b: i32) -> i32 {\n a + b\n}\n start 40 110 main.rs @@ -11,6 +12,7 @@ wait 10000 Callstack wait 10000 recursion stable 700 15000 snap hierarchy +snapstyle hierarchy # LookNext selects the caller signature; Enter opens it in the source pane. key space j n key enter |
