summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/typ/builtins-gui.json2
-rw-r--r--docs/typ/builtins-tui.json2
-rw-r--r--docs/typ/guide.typ21
-rw-r--r--docs/typ/reference.typ11
-rw-r--r--src/CHANGELOG.md6
-rw-r--r--src/Output.zig4
-rw-r--r--src/builtins.zig3
-rw-r--r--src/config.zig25
-rw-r--r--src/host_io.zig6
-rw-r--r--src/locations.zig45
-rw-r--r--src/lsp/lsp.zig6
-rw-r--r--src/lsp/lsp_client.zig81
-rw-r--r--src/pardes.zig33
-rw-r--r--test/behaviour/callstack.zig14
-rw-r--r--test/panes.zig30
-rw-r--r--test/snapshots/callstack-inline.golden65
-rw-r--r--test/snapshots/callstack-inline.snap30
-rw-r--r--test/snapshots/callstack.golden41
-rw-r--r--test/snapshots/callstack.snap4
19 files changed, 132 insertions, 297 deletions
diff --git a/docs/typ/builtins-gui.json b/docs/typ/builtins-gui.json
index 8150509c..9a8b2ced 100644
--- a/docs/typ/builtins-gui.json
+++ b/docs/typ/builtins-gui.json
@@ -6,9 +6,7 @@
{"name": "Callees", "leader": "SPC l C", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "List the functions the function under the cursor calls."},
{"name": "Callers", "leader": "SPC l c", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "List the callers of the function under the cursor."},
{"name": "Callstack", "leader": "SPC l b", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Show outermost callers first, with signatures and call sites (gc)."},
- {"name": "CallstackCorners", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "rounded, square", "doc": "Callstack tree corners: rounded (the default) or square; bare, it switches styles. Applies to the next Callstack query."},
{"name": "CallstackDepth", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": null, "doc": "Caller levels collected by Callstack, 1 through 64; default 8. Bare, it says the current limit."},
- {"name": "CallstackLayout", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "inline, stacked", "doc": "Callstack snippets below their locations (stacked, the default) or beside them (inline); bare, it switches layouts. Applies to the next Callstack query."},
{"name": "Changelog", "leader": "SPC h c", "also": ["topbar"], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "This build's version and what changed to reach it, printed into an output buffer the same way Config prints the live settings."},
{"name": "ChipShadow", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "In a terminal, a notice chip casts a cell's shadow right and down, on or off."},
{"name": "ClipPaste", "leader": "SPC p", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Paste the system clipboard after the selection."},
diff --git a/docs/typ/builtins-tui.json b/docs/typ/builtins-tui.json
index 5ce8aa64..f5fe199c 100644
--- a/docs/typ/builtins-tui.json
+++ b/docs/typ/builtins-tui.json
@@ -5,9 +5,7 @@
{"name": "Callees", "leader": "SPC l C", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "List the functions the function under the cursor calls."},
{"name": "Callers", "leader": "SPC l c", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "List the callers of the function under the cursor."},
{"name": "Callstack", "leader": "SPC l b", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Show outermost callers first, with signatures and call sites (gc)."},
- {"name": "CallstackCorners", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "rounded, square", "doc": "Callstack tree corners: rounded (the default) or square; bare, it switches styles. Applies to the next Callstack query."},
{"name": "CallstackDepth", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": null, "doc": "Caller levels collected by Callstack, 1 through 64; default 8. Bare, it says the current limit."},
- {"name": "CallstackLayout", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "inline, stacked", "doc": "Callstack snippets below their locations (stacked, the default) or beside them (inline); bare, it switches layouts. Applies to the next Callstack query."},
{"name": "Changelog", "leader": "SPC h c", "also": ["topbar"], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "This build's version and what changed to reach it, printed into an output buffer the same way Config prints the live settings."},
{"name": "ChipShadow", "leader": null, "also": [], "arg": true, "scope": "root", "setting": true, "choices": "on, off", "doc": "In a terminal, a notice chip casts a cell's shadow right and down, on or off."},
{"name": "ClipPaste", "leader": "SPC p", "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Paste the system clipboard after the selection."},
diff --git a/docs/typ/guide.typ b/docs/typ/guide.typ
index df8c79ce..29535c39 100644
--- a/docs/typ/guide.typ
+++ b/docs/typ/guide.typ
@@ -285,23 +285,16 @@ hierarchy deeper than the limit invites continuing from another function.
Every caller is listed: the walk runs as long as the server keeps answering,
says how many callers it has found on the message row once it takes more
than a second, and shows what it found if the server stops answering.
-Asking anything else stops it. A tree too big for one page (about 100,000
-rows, the memory one query may use) ends in a row saying so: running
-#word("Callstack") in `+Callstack` shows the next page, from where this
-one stopped, with that caller's own callers above it again.
+Asking anything else stops it. A tree bigger than one answer holds (about
+100,000 rows, the memory one query may use) stops there, its last row
+saying so: run #word("Callstack") on a function above to go on.
At each level, callers whose function or file name contains "test" come
-after the rest.
+after the rest. Each signature and call snippet sits below its location,
+aligned with the location text.
#word("CallstackDepth") reports the current caller depth;
`CallstackDepth 16` changes it for subsequent queries. The default is 8
-levels, and the accepted range is 1–64.
-
-`CallstackLayout stacked` (the default) puts each signature and call snippet below its
-location, aligned with the location text; `CallstackLayout inline` puts it
-beside the location again. A bare #word("CallstackLayout") switches modes.
-`CallstackCorners rounded` (the default) uses rounded tree guides;
-`CallstackCorners square` restores sharp corners. Bare #word("CallstackCorners")
-switches styles. Layout and corner changes apply to the next query. These settings are retained
-by #word("Dump") / #word("Restore").
+levels, the accepted range is 1–64, and #word("Dump") / #word("Restore")
+keep it.
= `pardes FILE` and `--wait` <editor>
diff --git a/docs/typ/reference.typ b/docs/typ/reference.typ
index e0d230d7..d3210814 100644
--- a/docs/typ/reference.typ
+++ b/docs/typ/reference.typ
@@ -266,15 +266,12 @@ A line written to #file("exec") is #word("Exec"):
language still holds the old name, a row per such file (zls renaming at
a declaration; from a use it reaches every file);
#word("Callstack") (#key("g c") or #key("SPC l b")) opens and focuses `+Callstack`,
- with static caller ancestry, tree-sitter signatures and Look locations
- for callers and call sites, test callers after the rest at each level; run
- in `+Callstack` itself, it shows the next page of a tree too big for one.
+ a tree of static caller ancestry: tree-sitter signatures and Look locations
+ for callers and call sites, each snippet below its location, test callers
+ after the rest at each level, and a tree bigger than one answer holds cut
+ there, its last row saying so.
#word("CallstackDepth") reports or sets the
runtime depth (1–64, default 8) for subsequent queries.
- `CallstackLayout stacked` (the default) aligns snippets below their locations;
- `CallstackLayout inline` places the snippets beside them.
- `CallstackCorners rounded` (the default) or `CallstackCorners square`
- selects the tree corner style for the next query; bare, it switches styles.
#word("Callers") and #word("Callees") keep their short
lists and single-result jumps.
#word("Diagnostics") and #word("Symbols") list the file's in `+Search`;
diff --git a/src/CHANGELOG.md b/src/CHANGELOG.md
index a3ee88c3..7a3f41b3 100644
--- a/src/CHANGELOG.md
+++ b/src/CHANGELOG.md
@@ -119,10 +119,8 @@
outermost callers first, tree-sitter signatures, depth guides and clickable call sites.
`gc` replaces the old move-to-viewport-center binding.
CallstackDepth sets the caller depth at runtime (1–64, default 8).
- CallstackLayout stacked is the default, aligning snippets below their
- locations with rounded tree corners; inline
- keeps them beside the locations. CallstackCorners square restores sharp
- tree corners; rounded remains the default.
+ Snippets sit below their locations, the tree's corners rounded; a tree
+ bigger than one answer holds (about 100,000 rows) stops there and says so.
Signatures use syntax colors; only calls to the queried function get
background emphasis, and tree guides continue through multiline signatures
and wrapped rows. Cross-directory call locations use shorter relative paths.
diff --git a/src/Output.zig b/src/Output.zig
index bc61dc11..abdf2664 100644
--- a/src/Output.zig
+++ b/src/Output.zig
@@ -145,8 +145,8 @@ pub fn decorateRow(output: ?State, line: []const u8, metadata: ?locations.Row) R
test "callstack guides and Look locations share result decoration" {
const from: State = .{ .from = .{ .query = .callstack } };
- const loc = decorateRow(from, "└──┬ lib.rs:2:8-10 fn add() {", null);
- try std.testing.expectEqual(@as(usize, "└──┬ lib.rs:2:8-10".len), loc.location_end);
+ const loc = decorateRow(from, "╰──┬ lib.rs:2:8-10 fn add() {", null);
+ try std.testing.expectEqual(@as(usize, "╰──┬ lib.rs:2:8-10".len), loc.location_end);
try std.testing.expect(!loc.declaration);
try std.testing.expect(!usesLocationsConfig(from.from));
try std.testing.expect(!traits(from.from).jumps);
diff --git a/src/builtins.zig b/src/builtins.zig
index 750000ba..c2be41a8 100644
--- a/src/builtins.zig
+++ b/src/builtins.zig
@@ -1973,9 +1973,6 @@ pub const WsDiagnostics = struct {
/// Show outermost callers first, with signatures and call sites (gc).
pub const Callstack = struct {
pub fn run(c: Ctx) void {
- // In +Callstack itself: the next page of what it shows.
- if (c.pane.file) |f| if (f.output) |o| if (std.meta.eql(o.from, panes.Output.Origin{ .query = .callstack }))
- return c.p.callstackMore(c.id);
c.p.lspRequest(c.id, .callstack, "");
}
};
diff --git a/src/config.zig b/src/config.zig
index 2542f99d..641ff463 100644
--- a/src/config.zig
+++ b/src/config.zig
@@ -90,8 +90,6 @@ pub const leader_path = paths: {
.Incl = null,
.Tab = null,
.CallstackDepth = null,
- .CallstackLayout = null,
- .CallstackCorners = null,
.Zerox = null,
.ClipYank = "y",
.ClipYankMain = "Y",
@@ -861,8 +859,6 @@ pub const Runtime = struct {
/// acme's Tab: a tab's width in cells, in every pane (config.tab_now
/// is what the drawing and the column arithmetic read).
tab: u16 = tab_width,
- callstack_layout: CallstackLayout = .stacked,
- callstack_corners: CallstackCorners = .rounded,
callstack_depth: u8 = @import("lsp/lsp.zig").callstack_default_depth,
/// Where a query pane goes (Query.zig): `attached`, under the pane that
/// asked, out of its rows alone; `column`, in the finder column.
@@ -878,12 +874,10 @@ pub const Runtime = struct {
pub const Pager = enum { pardes, off };
pub const TermImages = enum { real, petscii };
pub const JumpScope = enum { file, all };
- pub const CallstackLayout = enum { @"inline", stacked };
- pub const CallstackCorners = @import("lsp/lsp.zig").CallstackCorners;
pub const SearchPlace = enum { attached, column };
pub const SearchPane = enum { reuse, new };
/// A setting that is one of a few words, each an enum field of Runtime.
- pub const Choice = enum { pager, term_images, jump_scope, callstack_layout, callstack_corners, search_place, search_pane };
+ pub const Choice = enum { pager, term_images, jump_scope, search_place, search_pane };
/// shadow: a soft drop shadow. rim: a light hairline along the top of
/// the focused pane's tag rows. auto: a shadow on a light page; on a
@@ -1167,8 +1161,6 @@ pub const Runtime = struct {
.{ .word = "PagerColor", .action = .{ .toggle = .pager_color }, .doc = "A +Pager keeps its program's colours, on or off; for the next text paged." },
.{ .word = "TermImages", .action = .{ .choice = .term_images }, .doc = "How a new terminal draws its program's kitty graphics: real, as pixels where it can, or petscii, as glyph art." },
.{ .word = "JumpScope", .action = .{ .choice = .jump_scope }, .doc = "What Back and Forward keep to: file, the focused pane's file until it runs out that way, or all, every place in order." },
- .{ .word = "CallstackLayout", .action = .{ .choice = .callstack_layout }, .doc = "Callstack snippets below their locations (stacked, the default) or beside them (inline); bare, it switches layouts. Applies to the next Callstack query." },
- .{ .word = "CallstackCorners", .action = .{ .choice = .callstack_corners }, .doc = "Callstack tree corners: rounded (the default) or square; bare, it switches styles. Applies to the next Callstack query." },
.{ .word = "CallstackDepth", .action = .callstack_depth, .doc = "Caller levels collected by Callstack, 1 through 64; default 8. Bare, it says the current limit." },
.{ .word = "Tab", .action = .tab, .doc = "A tab's width in cells, 1 through 16, in every pane; bare, it says the width." },
.{ .word = "SearchPlace", .action = .{ .choice = .search_place }, .doc = "Where a query pane goes: attached, under the pane that asked, out of its rows alone, or column, in the finder column." },
@@ -1762,14 +1754,13 @@ pub const Runtime = struct {
.state = &state,
};
const values = [_][2][]const u8{
- .{ "TaglineSize", "73" }, .{ "WindowOpacity", "85" }, .{ "WindowBlur", "40" },
- .{ "MessageLinger", "1500" }, .{ "MessageFall", "1500" }, .{ "MessageDissolve", "1500" },
- .{ "DumpDir", "~/dumps" }, .{ "Crt", "3" }, .{ "Shader", "~/crt.glsl" },
- .{ "ShaderAnimation", "always" }, .{ "TermImages", "petscii" }, .{ "JumpScope", "all" },
- .{ "CallstackLayout", "inline" }, .{ "CallstackCorners", "square" }, .{ "SearchPlace", "column" },
- .{ "SearchPane", "new" }, .{ "Lift", "rim" }, .{ "Motion", "playful" },
- .{ "InactiveDim", "35" }, .{ "GripWidth", "200" }, .{ "CallstackDepth", "16" },
- .{ "Tab", "8" }, .{ "SearchRows", "12" },
+ .{ "TaglineSize", "73" }, .{ "WindowOpacity", "85" }, .{ "WindowBlur", "40" },
+ .{ "MessageLinger", "1500" }, .{ "MessageFall", "1500" }, .{ "MessageDissolve", "1500" },
+ .{ "DumpDir", "~/dumps" }, .{ "Crt", "3" }, .{ "Shader", "~/crt.glsl" },
+ .{ "ShaderAnimation", "always" }, .{ "TermImages", "petscii" }, .{ "JumpScope", "all" },
+ .{ "SearchPlace", "column" }, .{ "SearchPane", "new" }, .{ "Lift", "rim" },
+ .{ "Motion", "playful" }, .{ "InactiveDim", "35" }, .{ "GripWidth", "200" },
+ .{ "CallstackDepth", "16" }, .{ "Tab", "8" }, .{ "SearchRows", "12" },
};
for (values) |v| try std.testing.expect(apply(&state, find(v[0]).?, v[1]));
try std.testing.expect(state.font.requested_name.set("Wanted Mono"));
diff --git a/src/host_io.zig b/src/host_io.zig
index ad7c77dd..a04bf7ce 100644
--- a/src/host_io.zig
+++ b/src/host_io.zig
@@ -617,7 +617,6 @@ pub const Lsp = struct {
/// One language query, owned by the worker that runs it.
pub const Job = struct {
callstack_depth: u8 = pardes.lsp.callstack_default_depth,
- callstack_corners: pardes.lsp.CallstackCorners = .rounded,
id: u32,
kind: pardes.lsp.Kind,
offset: u32,
@@ -661,7 +660,6 @@ pub const Lsp = struct {
errdefer gpa.free(root);
job.* = .{
.callstack_depth = core.settings.callstack_depth,
- .callstack_corners = core.settings.callstack_corners,
.id = req.id,
.kind = req.kind,
.offset = req.offset,
@@ -748,7 +746,6 @@ pub const Lsp = struct {
.root = job.root,
.others = job.others,
.callstack_depth = job.callstack_depth,
- .callstack_corners = job.callstack_corners,
.budget = &arena,
}, &out.writer) catch {
deliver(ctx, job.id, null);
@@ -767,7 +764,6 @@ pub const Lsp = struct {
defer core.deinit();
core.settings.callstack_depth = 16;
- core.settings.callstack_corners = .square;
var needle: [6]u8 = "needle".*;
const job = try snapshot(gpa, core, .{
.id = 7,
@@ -779,8 +775,6 @@ pub const Lsp = struct {
defer job.free(gpa);
core.settings.callstack_depth = 2;
- core.settings.callstack_corners = .rounded;
- try std.testing.expectEqual(pardes.lsp.CallstackCorners.square, job.callstack_corners);
try std.testing.expectEqual(@as(u8, 16), job.callstack_depth);
try std.testing.expectEqual(@as(u32, 7), job.id);
try std.testing.expectEqual(pardes.lsp.Kind.status, job.kind);
diff --git a/src/locations.zig b/src/locations.zig
index 889a45a0..e8c31bf0 100644
--- a/src/locations.zig
+++ b/src/locations.zig
@@ -243,11 +243,11 @@ pub fn sourceText(p: *pardes.Pardes, arena: std.mem.Allocator, dir: []const u8,
pub fn treePrefix(line: []const u8) struct { end: usize, branch: bool } {
var at: usize = 0;
while (at < line.len) {
- for ([_][]const u8{ "╰──┬ ", "├──╮ ", "╰──╮ ", "├─── ", "╰─── ", "├──┬ ", "└──┬ ", "└─── " }) |branch| {
+ for ([_][]const u8{ "├──┬ ", "╰──┬ ", "├─── ", "╰─── " }) |branch| {
if (std.mem.startsWith(u8, line[at..], branch)) return .{ .end = at + branch.len, .branch = true };
}
- if (std.mem.startsWith(u8, line[at..], "├─ ") or std.mem.startsWith(u8, line[at..], "└─ ") or std.mem.startsWith(u8, line[at..], "╰─ "))
- return .{ .end = at + "└─ ".len, .branch = false };
+ if (std.mem.startsWith(u8, line[at..], "├─ ") or std.mem.startsWith(u8, line[at..], "╰─ "))
+ return .{ .end = at + "╰─ ".len, .branch = false };
if (std.mem.startsWith(u8, line[at..], "│")) {
at += "│".len;
} else if (line[at] == ' ') {
@@ -267,7 +267,7 @@ pub fn treeContinuation(line: []const u8, buffer: []u8, max_cells: usize) []cons
var end: usize = 0;
while (it.nextCodepoint()) |cp| {
if (cells >= max_cells) break;
- out.writeAll(if (cp == '│' or cp == '├' or cp == '┬' or cp == '╮') "│" else " ") catch break;
+ out.writeAll(if (cp == '│' or cp == '├' or cp == '┬') "│" else " ") catch break;
cells += 1;
if (cp != ' ') end = out.buffered().len;
}
@@ -280,7 +280,7 @@ pub fn treeContinuation(line: []const u8, buffer: []u8, max_cells: usize) []cons
const Resolved = struct { code: []const u8 = "", colors: []const u8 = &.{}, source_row: usize = 0 };
/// Each Callstack row's code (its call site's line, or a caller's header) and
-/// colors, by input line. A page spans thousands of files, so they are taken
+/// colors, by input line. A tree spans thousands of files, so they are taken
/// a file at a time: grouped by path, each file read, line-indexed and
/// analyzed once, its rows' code and colors copied out, and the file let go
/// before the next. Row by row, the cache compared the whole source each
@@ -377,7 +377,6 @@ pub fn formatCallstack(p: *pardes.Pardes, dir: []const u8, input: []const u8) !R
errdefer out.deinit();
var rows: std.ArrayList(Row) = .empty;
errdefer freeRowList(p.gpa, &rows);
- const stacked = p.settings.callstack_layout == .stacked;
const resolved = try resolveCallstack(p, arena, dir, input);
var lines = std.mem.splitScalar(u8, std.mem.trimEnd(u8, input, "\n"), '\n');
var index: usize = 0;
@@ -397,33 +396,21 @@ pub fn formatCallstack(p: *pardes.Pardes, dir: []const u8, input: []const u8) !R
var source_row = resolved[index].source_row;
const recursion = prefix.branch and std.mem.endsWith(u8, line, " ↻ recursion");
const first_line = code[0 .. std.mem.indexOfScalar(u8, code, '\n') orelse code.len];
- const source_indent = if (stacked) first_line.len - std.mem.trimStart(u8, first_line, " \t").len else 0;
- if (stacked) {
- const end = prefix.end + target.end;
- try out.writer.print("{s}\n", .{line[0..end]});
- try appendMetadata(p.gpa, &rows, .{ .path = target.path, .at = target.at, .label = "", .code = "", .original = null, .mark_occurrence = false }, .match, end, end, false);
- }
+ const source_indent = first_line.len - std.mem.trimStart(u8, first_line, " \t").len;
+ // The location on a row of its own, its code below it, aligned with it.
+ const end = prefix.end + target.end;
+ try out.writer.print("{s}\n", .{line[0..end]});
+ try appendMetadata(p.gpa, &rows, .{ .path = target.path, .at = target.at, .label = "", .code = "", .original = null, .mark_occurrence = false }, .match, end, end, false);
var header_lines = std.mem.splitScalar(u8, code, '\n');
var first = true;
var color_offset: usize = 0;
while (header_lines.next()) |code_line| {
const start = out.written().len;
- if (stacked) {
- var guide_buf: [1024]u8 = undefined;
- const guide = treeContinuation(line, &guide_buf, std.math.maxInt(usize));
- try out.writer.writeAll(guide);
- const width = pardes.panes.File.displayWidth(line[0..prefix.end]);
- try out.writer.splatByteAll(' ', width -| pardes.panes.File.displayWidth(guide));
- } else if (first) {
- try out.writer.writeAll(line[0 .. prefix.end + target.end]);
- try out.writer.writeByte(' ');
- } else {
- const branch_start = prefix.end - "└──┬ ".len;
- try out.writer.writeAll(line[0..branch_start]);
- try out.writer.writeAll(if (std.mem.startsWith(u8, line[branch_start..], "├")) "│ " else " ");
- try out.writer.writeAll(if (std.mem.endsWith(u8, line[0..prefix.end], "┬ ") or std.mem.endsWith(u8, line[0..prefix.end], "╮ ")) "│ " else " ");
- try out.writer.splatByteAll(' ', pardes.panes.File.displayWidth(line[prefix.end..][0..target.end]) + 1);
- }
+ var guide_buf: [1024]u8 = undefined;
+ const guide = treeContinuation(line, &guide_buf, std.math.maxInt(usize));
+ try out.writer.writeAll(guide);
+ const width = pardes.panes.File.displayWidth(line[0..prefix.end]);
+ try out.writer.splatByteAll(' ', width -| pardes.panes.File.displayWidth(guide));
const code_start = out.written().len - start;
const trim = @min(source_indent, code_line.len - std.mem.trimStart(u8, code_line, " \t").len);
try out.writer.writeAll(code_line[trim..]);
@@ -439,7 +426,7 @@ pub fn formatCallstack(p: *pardes.Pardes, dir: []const u8, input: []const u8) !R
.original = null,
.mark_occurrence = focus and !prefix.branch,
.colors = if (colors.len >= color_offset + code_line.len) colors[color_offset + trim ..][0 .. code_line.len - trim] else &.{},
- }, if (first) (if (stacked) .preview else .match) else .context, if (first and !stacked) prefix.end + target.end else 0, code_start, true);
+ }, if (first) .preview else .context, 0, code_start, true);
// Recursion notes are prose, outside the source snapshot.
if (recursion_note) {
const added = " ↻ recursion".len;
diff --git a/src/lsp/lsp.zig b/src/lsp/lsp.zig
index 2781077a..190c05f8 100644
--- a/src/lsp/lsp.zig
+++ b/src/lsp/lsp.zig
@@ -26,17 +26,11 @@ pub const Kind = enum {
};
pub const callstack_match = "@callstack-match ";
-/// The last row of a Callstack page that stopped full: `<path> <callers>`,
-/// the entry indices from the top the next page starts at (`3.0.17`), and
-/// how many callers this page holds.
-pub const callstack_more = "@callstack-more ";
-pub const CallstackCorners = enum { rounded, square };
pub const callstack_default_depth: u8 = 8;
pub const callstack_max_depth: u8 = 64;
pub const Req = struct {
callstack_depth: u8 = callstack_default_depth,
- callstack_corners: CallstackCorners = .rounded,
kind: Kind,
path: []const u8,
source: [:0]const u8,
diff --git a/src/lsp/lsp_client.zig b/src/lsp/lsp_client.zig
index f2c186a8..40c287b0 100644
--- a/src/lsp/lsp_client.zig
+++ b/src/lsp/lsp_client.zig
@@ -545,7 +545,7 @@ fn run(c: *Conn, io: std.Io, si: usize, arena: std.mem.Allocator, req: lsp.Req,
};
const pos = posOf(req.source, req.offset, c.caps.enc);
- var cx: Cx = .{ .arena = arena, .base = req.root, .cur_path = req.path, .cur_src = req.source, .out = out, .fixed_out = true, .relative_parents = req.kind == .callstack, .callstack_corners = req.callstack_corners };
+ var cx: Cx = .{ .arena = arena, .base = req.root, .cur_path = req.path, .cur_src = req.source, .out = out, .fixed_out = true, .relative_parents = req.kind == .callstack };
for (req.others) |doc| try cx.files.append(arena, .{ .path = doc.path, .text = doc.source });
tr.note("server {s} (pid {d}), root {s}, {s} columns", .{
@tagName(c.state), c.pid, c.root, @tagName(c.caps.enc),
@@ -659,7 +659,7 @@ fn run(c: *Conn, io: std.Io, si: usize, arena: std.mem.Allocator, req: lsp.Req,
n += 1;
}
},
- .callstack => try callstack(c, io, si, arena, &cx, uri.items, pos, deadline, tr, req.callstack_depth, req.budget, req.arg),
+ .callstack => try callstack(c, io, si, arena, &cx, uri.items, pos, deadline, tr, req.callstack_depth, req.budget),
.incoming_calls => try hierarchy(c, io, si, arena, &cx, uri.items, pos, deadline, .incoming, tr),
.outgoing_calls => try hierarchy(c, io, si, arena, &cx, uri.items, pos, deadline, .outgoing, tr),
.supertypes => try hierarchy(c, io, si, arena, &cx, uri.items, pos, deadline, .supers, tr),
@@ -914,17 +914,8 @@ const CallTree = struct {
narrated: bool = false,
siblings: [lsp.callstack_max_depth]bool = @splat(false),
rendered: usize = 0,
- /// Paging. A page starts at `start`, a path of entry indices from the
- /// top (empty: the start), skipping what is before it at each level;
- /// `rows` and `bytes` count what rendering takes, and the walk stops
- /// before their caps at `cut`, which the next page starts at (`more`).
- /// The ancestors on the path are shown again on it, as context.
- start: [lsp.callstack_max_depth]u32 = undefined,
- start_len: usize = 0,
- at: [lsp.callstack_max_depth]u32 = undefined,
- cut: [lsp.callstack_max_depth]u32 = undefined,
- cut_len: usize = 0,
- more: bool = false,
+ /// The rows rendering the tree takes: the walk stops before `row_cap`,
+ /// as at the memory limit (`out_of_memory`).
rows: usize = 0,
row_cap: usize = max_rows - 16,
/// The bytes those rows take, over-estimated (the uri for the path it
@@ -1013,7 +1004,7 @@ fn validCaller(entry: std.json.Value) bool {
rangeOf(get(from, "selectionRange") orelse get(from, "range")) != null;
}
-fn callstack(c: *Conn, io: std.Io, si: usize, arena: std.mem.Allocator, cx: *Cx, uri: []const u8, pos: Pos, deadline: i64, tr: *Trace, max_depth: u8, budget: ?*const std.heap.FixedBufferAllocator, arg: []const u8) Err!void {
+fn callstack(c: *Conn, io: std.Io, si: usize, arena: std.mem.Allocator, cx: *Cx, uri: []const u8, pos: Pos, deadline: i64, tr: *Trace, max_depth: u8, budget: ?*const std.heap.FixedBufferAllocator) Err!void {
if (!c.caps.call_hier) return lsp.none(cx.out, "{s} does not answer call hierarchy (no callHierarchyProvider)", .{specs[si].name});
const b = try atPos(arena, uri, pos);
const prepared = (try call(c, io, arena, "textDocument/prepareCallHierarchy", b.items, deadline)) orelse return;
@@ -1035,25 +1026,15 @@ fn callstack(c: *Conn, io: std.Io, si: usize, arena: std.mem.Allocator, cx: *Cx,
.si = si,
.started_ms = nowMs(),
.budget = budget,
- // The page ends while the answer's writer has room for the rest.
+ // The walk stops while the answer's writer has room for the rest.
.byte_cap = if (cx.fixed_out) (cx.out.buffer.len - cx.out.end) -| (1 << 20) else std.math.maxInt(usize),
};
- var steps = std.mem.tokenizeScalar(u8, std.mem.trim(u8, arg, " \n"), '.');
- while (steps.next()) |step| {
- if (tree.start_len == tree.start.len) break;
- tree.start[tree.start_len] = std.fmt.parseInt(u32, step, 10) catch break;
- tree.start_len += 1;
- }
const incoming = try hierarchyResult(c, io, parse, item, "callHierarchy/incomingCalls", deadline);
- const count = try collectCallers(c, io, arena, if (budget != null) &parse_fba else null, item, incoming, &tree, 0, tree.start_len > 0);
+ const count = try collectCallers(c, io, arena, if (budget != null) &parse_fba else null, item, incoming, &tree, 0);
if (tree.narrated) post(si, .always, "Callstack: {d} callers", .{tree.collected});
- if (count == 0 and tree.start_len == 0) try cx.out.writeAll("No callers reported\n");
+ if (count == 0) try cx.out.writeAll("No callers reported\n");
try renderCallers(cx, c.caps.enc, &tree, tree.roots.items, 0);
- if (tree.more) {
- try cx.out.writeAll(lsp.callstack_more);
- for (tree.cut[0..tree.cut_len], 0..) |index, level| try cx.out.print("{s}{d}", .{ if (level == 0) "" else ".", index });
- try cx.out.print(" {d}\n", .{tree.collected});
- } else if (tree.out_of_time) {
+ if (tree.out_of_time) {
try cx.out.writeAll("… the language server ran out of time; continue from a function above with Callstack\n");
} else if (tree.out_of_memory) {
try cx.out.writeAll("… stopped at the query's memory limit; continue from a function above with Callstack\n");
@@ -1064,28 +1045,16 @@ fn callstack(c: *Conn, io: std.Io, si: usize, arena: std.mem.Allocator, cx: *Cx,
/// No caller count and no overall deadline: the walk narrates itself on the
/// message row after a second, and it stops when a request goes unanswered
-/// (what was collected is shown), when the page is full (the rest is the
-/// next page), or when the shell cancels it for a newer query.
-fn collectCallers(c: *Conn, io: std.Io, arena: std.mem.Allocator, parse: ?*std.heap.FixedBufferAllocator, focus: std.json.Value, incoming: ?std.json.Value, tree: *CallTree, depth: usize, on_path: bool) Err!usize {
+/// or the answer is full (what was collected is shown, its last row saying
+/// so), or when the shell cancels it for a newer query.
+fn collectCallers(c: *Conn, io: std.Io, arena: std.mem.Allocator, parse: ?*std.heap.FixedBufferAllocator, focus: std.json.Value, incoming: ?std.json.Value, tree: *CallTree, depth: usize) Err!usize {
var count: usize = 0;
- for (items(incoming), 0..) |entry, index| {
- // A later page skips what the pages before it walked.
- const resuming = on_path and depth < tree.start_len;
- if (resuming and index < tree.start[depth]) continue;
- tree.at[depth] = @intCast(index);
+ for (items(incoming)) |entry| {
if (tree.budget) |b| if (b.buffer.len - b.end_index < callstack_reserve) {
tree.out_of_memory = true;
};
- if (!tree.more and (tree.rows >= tree.row_cap or tree.bytes >= tree.byte_cap or tree.out_of_memory)) {
- // The page is full: the next goes on here. Never where this
- // one began, which would page in place: past that entry.
- tree.more = true;
- tree.cut_len = depth + 1;
- @memcpy(tree.cut[0..tree.cut_len], tree.at[0..tree.cut_len]);
- if (tree.cut_len == tree.start_len and std.mem.eql(u32, tree.cut[0..tree.cut_len], tree.start[0..tree.start_len]))
- tree.cut[depth] += 1;
- }
- if (tree.out_of_time or tree.more) break;
+ if (tree.rows >= tree.row_cap or tree.bytes >= tree.byte_cap) tree.out_of_memory = true;
+ if (tree.out_of_time or tree.out_of_memory) break;
if (!validCaller(entry)) continue;
const from = get(entry, "from").?;
const cycle = sameItem(focus, from) or for (tree.path[0..depth]) |ancestor| {
@@ -1113,15 +1082,14 @@ fn collectCallers(c: *Conn, io: std.Io, arena: std.mem.Allocator, parse: ?*std.h
break :blk null;
},
// A response bigger than the parse region: this caller
- // stops here, the page with it.
+ // stops here, the walk with it.
error.OutOfMemory => blk: {
tree.out_of_memory = true;
break :blk null;
},
else => return e,
};
- const deeper = resuming and index == tree.start[depth] and depth + 1 < tree.start_len;
- if (!tree.out_of_time and !tree.out_of_memory) children = try collectCallers(c, io, arena, parse, focus, ancestors, tree, depth + 1, deeper);
+ if (!tree.out_of_time and !tree.out_of_memory) children = try collectCallers(c, io, arena, parse, focus, ancestors, tree, depth + 1);
}
}
if (children == 0) try tree.addPath(arena, tree.path[0 .. depth + 1], cycle);
@@ -1162,8 +1130,7 @@ fn renderCallers(cx: *Cx, enc: Enc, tree: *CallTree, children: []usize, depth: u
const more = index + 1 < children.len;
try callPrefix(cx.out, tree, depth);
const has_children = node.children.items.len > 0 or node.ranges.items.len > 0;
- const rounded = cx.callstack_corners == .rounded;
- try cx.out.writeAll(if (more) "├" else if (rounded) "╰" else "└");
+ try cx.out.writeAll(if (more) "├" else "╰");
try cx.out.writeAll(if (has_children) "──┬ " else "─── ");
const name = flat(cx.arena, node.call.name);
const label = if (node.cycle) try std.fmt.allocPrint(cx.arena, "{s} ↻ recursion", .{name}) else name;
@@ -1182,7 +1149,7 @@ fn renderCallers(cx: *Cx, enc: Enc, tree: *CallTree, children: []usize, depth: u
}
if (site.focus) try cx.out.writeAll(lsp.callstack_match);
try callPrefix(cx.out, tree, depth + 1);
- try cx.out.writeAll(if (node.children.items.len > 0 or site_index + 1 < node.ranges.items.len) "├─ " else if (rounded) "╰─ " else "└─ ");
+ try cx.out.writeAll(if (node.children.items.len > 0 or site_index + 1 < node.ranges.items.len) "├─ " else "╰─ ");
try emitAt(cx, enc, node.call.uri, site.range, "");
}
try renderCallers(cx, enc, tree, node.children.items, depth + 1);
@@ -1280,7 +1247,6 @@ const Cx = struct {
no_text: bool = false,
rows: usize = 0,
relative_parents: bool = false,
- callstack_corners: lsp.CallstackCorners = .rounded,
files: std.ArrayList(struct { path: []const u8, text: []const u8 }) = .empty,
fn text(cx: *Cx, path: []const u8) ?[]const u8 {
@@ -2576,15 +2542,6 @@ test "caller trees reverse incoming paths and merge shared callers and sites" {
try std.testing.expect(std.mem.indexOf(u8, text, "page_left();").? < std.mem.indexOf(u8, text, "page_right();").?);
try std.testing.expect(std.mem.indexOf(u8, text, "├──┬ test.c:4:") != null);
try std.testing.expect(std.mem.indexOf(u8, text, "╰──┬ test.c:1:") != null);
- cx.callstack_corners = .square;
- tree.rendered = 0;
- const square_start = out.written().len;
- try renderCallers(&cx, .utf8, &tree, tree.roots.items, 0);
- const square = out.written()[square_start..];
- try std.testing.expect(std.mem.indexOf(u8, square, "├──┬ test.c:4:") != null);
- try std.testing.expect(std.mem.indexOf(u8, square, "└──┬ test.c:1:") != null);
- try std.testing.expect(std.mem.indexOf(u8, square, "╰") == null);
- try std.testing.expect(std.mem.indexOf(u8, square, "╮") == null);
var recursive: CallTree = .{};
try recursive.addPath(arena, &.{ entries[0], entries[0] }, true);
try std.testing.expect(!recursive.nodes.items[recursive.roots.items[0]].cycle);
diff --git a/src/pardes.zig b/src/pardes.zig
index 334d66e2..88045147 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -3989,10 +3989,6 @@ pub const Pardes = struct {
/// The last query asked (Lspwhy explains it): its kind, argument, and
/// the pane and place it was asked at.
lsp_last: ?struct { kind: lsp.Kind, arg: Effect.Buf(128), serial: u32, offset: u32 } = null,
- /// The Callstack page `+Callstack` shows stopped short: its file's pane,
- /// the place it was asked at, and the direct caller the next page starts
- /// at. Callstack run in `+Callstack` asks for it.
- callstack_more: ?struct { serial: u32, offset: u32, next: Effect.Buf(128) } = null,
lsp_wait: ?struct {
id: u32,
kind: lsp.Kind,
@@ -6408,19 +6404,6 @@ pub const Pardes = struct {
pub const SavePath = Effect.Buf(effect_path_cap);
pub fn lspRequest(p: *Pardes, asked: usize, kind: lsp.Kind, arg_in: []const u8) void {
- p.lspRequestAt(asked, kind, arg_in, null);
- }
-
- /// The next page of the Callstack `+Callstack` shows, asked where the
- /// first was.
- pub fn callstackMore(p: *Pardes, from: usize) void {
- const more = p.callstack_more orelse return p.reportFailure(from, "Callstack: this is the last page; run it in a file to start again");
- const id = p.paneBySerial(more.serial) orelse return p.reportFailure(from, "Callstack: the file it was asked in is closed");
- p.lspRequestAt(id, .callstack, more.next.slice(), more.offset);
- }
-
- /// `lspRequest` at byte `at` of the pane's file rather than its cursor.
- fn lspRequestAt(p: *Pardes, asked: usize, kind: lsp.Kind, arg_in: []const u8, at_byte: ?u32) void {
var arg = arg_in;
if (!normal.multiOnce(p)) return; // one question per keystroke, from the primary
// Lspwhy narrates the last query where it was asked -- that pane's
@@ -6444,7 +6427,7 @@ pub const Pardes = struct {
(!zig_buf and std.mem.indexOfAny(u8, arg, " \t\r\n\"\\") != null))
return p.reportFailure(id, std.fmt.bufPrint(&said, "Rename: {s} is no name", .{arg}) catch "Rename: no name");
}
- var off = if (at_byte) |at| @min(at, if (pane.file) |f| f.content.len else 0) else if (pane.file) |f| modal.offsetAt(f.content, .{
+ var off = if (pane.file) |f| modal.offsetAt(f.content, .{
.row = @intCast(@max(0, pane.body.cur_row)),
.col = @intCast(@max(0, pane.body.cur_col)),
}) else 0;
@@ -6760,17 +6743,7 @@ pub const Pardes = struct {
return;
};
const dir = if (pane.file) |f| panes.Dir.ofName(f.path) else pane.cwdSlice();
- // A Callstack page that stops short ends in its marker: said as a
- // row naming the word that shows the next page, and kept.
- if (w.kind == .callstack) p.callstack_more = null;
- const marker = if (w.kind == .callstack) std.mem.lastIndexOf(u8, rows, lsp.callstack_more) else null;
- const content = if (marker) |at| more: {
- var fields = std.mem.tokenizeAny(u8, rows[at + lsp.callstack_more.len ..], " \n");
- const next = fields.next() orelse "";
- const shown = fields.next() orelse "?";
- if (p.lsp_last) |last| p.callstack_more = .{ .serial = w.serial, .offset = last.offset, .next = .from(next) };
- break :more std.fmt.allocPrint(p.gpa, "{s}… {s} callers on this page, more after them: Callstack here shows the next page\n", .{ rows[0..at], shown }) catch return;
- } else p.gpa.dupe(u8, rows) catch return;
+ const content = p.gpa.dupe(u8, rows) catch return;
const serial_before = p.next_serial;
p.fs.refilled = null;
panes.Output.fillResults(p, w.pane, dir, from, w.arg.slice(), content, null) catch |err| {
@@ -8167,7 +8140,7 @@ test "Callstack always opens and focuses its own pane, reusing it for another sy
const source = p.panes[0].?;
p.lspRequest(0, .callstack, "");
const first = p.lsp_wait orelse return error.NoRequest;
- p.lspResponse(first.id, "└──┬ /test.txt:1:4-7 work\n@callstack-match └─ /test.txt:1:4-7 fn work() {}\n");
+ p.lspResponse(first.id, "╰──┬ /test.txt:1:4-7 work\n@callstack-match ╰─ /test.txt:1:4-7 fn work() {}\n");
const report = p.panes[p.active].?;
try std.testing.expect(report != source);
try std.testing.expect(std.mem.endsWith(u8, report.file.?.path, "/+Callstack"));
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