From c50226bdad46ed69643079e7c6f3e8ade3a034a1 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 17 Nov 2026 00:05:09 -0300 Subject: colors: a style byte's four high bits are grounds a theme resolves, not a diff's: syntax.ground_add and ground_del (a row's hue), ground_emph (the stronger ground), ground_line (the faint one), the byte as it was; DiffTints moves from File.zig to colors.zig as Grounds (an add and a del Ground: row, emph, line, ink), the same Oklab mixes and marker contrast; the painter has one rule, a row's first byte says its ground (emph the stronger to the pane's edge, line the faint, neither none, its marker in the hue) and a later byte's emph is its cell's, so it stops asking the pane's colour algorithm (`row_tint = algo == .diff`) and works the grounds out once a frame only for a row that names a hue; highlightDiff marks an added or removed line's first byte emph, the strong row a .diff's rows always had; recolorDiffOutput reads the same Grounds; goldens unchanged (diffview, pagercolor, diffstack), render of the 50k-line file 11,723,421 user instructions a frame before and 11,724,208 after (+0.007%, perf stat over ReleaseFast pardes-perf, 210 frames less 10) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- src/hunks.zig | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/hunks.zig') diff --git a/src/hunks.zig b/src/hunks.zig index 8f4b4233..19246392 100644 --- a/src/hunks.zig +++ b/src/hunks.zig @@ -331,10 +331,10 @@ fn flush(out: *Out, hunk: *Hunk, memo: *SourceMemo, dir: []const u8) !void { // has it: the marker coloured, the line as its file's. for (lines) |line| { const flag: u8 = switch (line.kind) { - .added => syntax.diff_added, - .removed => syntax.diff_removed, + .added => syntax.ground_add, + .removed => syntax.ground_del, else => 0, - } | @as(u8, if (line.kind != .context and !line.paired) syntax.diff_whole else 0); + } | @as(u8, if (line.kind != .context and !line.paired) syntax.ground_line else 0); const text = try std.fmt.allocPrint(arena, "{c}{s}", .{ @as(u8, switch (line.kind) { .added => '+', .removed => '-', @@ -389,10 +389,10 @@ fn inferEdits(arena: std.mem.Allocator, minus: []HunkLine, plus: []HunkLine) !vo const marks = annotate(pair, &alignment, m.code, plus[j].code) catch continue; if (marks.distance > max_line_distance) continue; for (marks.minus) |r| for (m.styles[r[0]..r[1]]) |*b| { - b.* |= syntax.diff_emph; + b.* |= syntax.ground_emph; }; for (marks.plus) |r| for (plus[j].styles[r[0]..r[1]]) |*b| { - b.* |= syntax.diff_emph; + b.* |= syntax.ground_emph; }; m.paired = true; plus[j].paired = true; @@ -583,7 +583,7 @@ const testing = std.testing; fn emphasised(line: HunkLine) ![]const u8 { var out: std.ArrayList(u8) = .empty; - for (line.code, line.styles) |c, s| try out.append(testing.allocator, if (s & syntax.diff_emph != 0) c else '.'); + for (line.code, line.styles) |c, s| try out.append(testing.allocator, if (s & syntax.ground_emph != 0) c else '.'); return out.toOwnedSlice(testing.allocator); } @@ -653,13 +653,13 @@ test "a diff stacks to a label a hunk and its lines, markers gone, tinted and st try testing.expectEqual(@as(usize, "nowhere/x.txt:2".len), result.rows[0].location_end); try testing.expect(result.rows[1].declaration); const removed = result.rows[3]; - try testing.expect(removed.colors[0] & syntax.diff_removed != 0); + try testing.expect(removed.colors[0] & syntax.ground_del != 0); // Paired with the line it changed: no whole-line tint. - try testing.expect(removed.colors[0] & syntax.diff_whole == 0); - try testing.expect(removed.colors[1] & syntax.diff_emph != 0); - try testing.expect(removed.colors[5] & syntax.diff_emph == 0); - try testing.expect(result.rows[4].colors[0] & syntax.diff_added != 0); - try testing.expect(result.rows[2].colors[0] & (syntax.diff_added | syntax.diff_removed) == 0); + try testing.expect(removed.colors[0] & syntax.ground_line == 0); + try testing.expect(removed.colors[1] & syntax.ground_emph != 0); + try testing.expect(removed.colors[5] & syntax.ground_emph == 0); + try testing.expect(result.rows[4].colors[0] & syntax.ground_add != 0); + try testing.expect(result.rows[2].colors[0] & (syntax.ground_add | syntax.ground_del) == 0); } test "a hunk the file has moved since is found where it went, inside its declaration" { -- cgit v1.3 From 5caef6d571f51e98eab3a48c063678ad35e09cce Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 17 Nov 2026 00:25:19 -0300 Subject: hunks: format stacks for a narrow Ctx, not a *Pardes: its two allocators, `source(dir, path)` (a file as a look from dir finds it), `declarations(path, bytes)` and the one setting, tslocations; Output.openDiff gives the editor's, its reads the same taped sites as before (locations.sourceText: an open pane's text, else fs.read) and its declarations the locations cache's, so a replica still replays the authority's bytes; displayWidth from File.zig itself; the four format tests read the disk through a Ctx of their own and stop booting a whole Pardes (the look and refill tests still drive the editor); goldens unchanged Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- src/Output.zig | 29 ++++++++++- src/hunks.zig | 151 ++++++++++++++++++++++++++++++++++++++------------------- 2 files changed, 128 insertions(+), 52 deletions(-) (limited to 'src/hunks.zig') diff --git a/src/Output.zig b/src/Output.zig index 0c6fdfc2..d4be640c 100644 --- a/src/Output.zig +++ b/src/Output.zig @@ -490,8 +490,33 @@ pub fn fillRows(p: *Pardes, id: usize, dir: []const u8, from: Origin, arg: []con /// NoHunks when there is none in it. pub fn openDiff(p: *Pardes, id: usize, path: []const u8, content: []const u8) !usize { const dir = std.Io.Dir.path.dirname(path) orelse p.sessionDir(); - const root = hunks.sourceRoot(p, dir, content); - const result = try hunks.format(p, root, content); + // Each file read is a site of the step's tape (fs.zig): a replica + // replays the authority's bytes and reads no disk of its own. + const Read = struct { + fn source(ctx: *const hunks.Ctx, from: []const u8, name: []const u8) ?hunks.Source { + const pp: *Pardes = @ptrCast(@alignCast(ctx.host)); + const text = locations.sourceText(pp, ctx.arena, from, name) orelse return null; + return .{ .path = text.path, .bytes = text.bytes }; + } + fn declarations(ctx: *const hunks.Ctx, name: []const u8, bytes: []const u8) error{OutOfMemory}![]const @import("syntax.zig").ContextDeclaration { + const pp: *Pardes = @ptrCast(@alignCast(ctx.host)); + var hit = pp.locations_cache.get(pp.tree_sitter_gpa, name, bytes, true, false) catch + locations.Cache.Hit{ .analysis = @import("syntax.zig").analyzeSource(ctx.arena, name, bytes, true, false) catch .{} }; + defer hit.deinit(pp.tree_sitter_gpa); + // The cache's may go at its next use: kept for the call. + return ctx.arena.dupe(@import("syntax.zig").ContextDeclaration, hit.analysis.declarations); + } + }; + const ctx: hunks.Ctx = .{ + .gpa = p.gpa, + .arena = p.scratch.allocator(), + .source = Read.source, + .declarations = Read.declarations, + .host = p, + .tslocations = p.locations_config.tslocations, + }; + const root = hunks.sourceRoot(&ctx, dir, content); + const result = try hunks.format(&ctx, root, content); errdefer { p.gpa.free(result.content); locations.freeRows(p.gpa, result.rows); diff --git a/src/hunks.zig b/src/hunks.zig index 19246392..28fffa38 100644 --- a/src/hunks.zig +++ b/src/hunks.zig @@ -6,21 +6,43 @@ //! a tinted ground as delta emphasises them (its edits.rs and align.rs, here as `inferEdits` //! and `Alignment`). const std = @import("std"); -const pardes = @import("pardes.zig"); const diff = @import("diff.zig"); const syntax = @import("syntax.zig"); const locations = @import("locations.zig"); -const Pardes = pardes.Pardes; const Row = locations.Row; +/// What `format` takes of the editor it stacks for: its allocators, the +/// files a diff names read as the editor reads them (in pardes an open +/// pane's text, else the disk's, each read a site of the step's tape: +/// Output.openDiff), their declarations, and one setting. +pub const Ctx = struct { + /// The text and rows made, the caller's. + gpa: std.mem.Allocator, + /// All else, the call's. + arena: std.mem.Allocator, + /// `path` as a look from `dir` finds it, its text the arena's (or the + /// editor's, good for the call); null when it is not there. + source: *const fn (ctx: *const Ctx, dir: []const u8, path: []const u8) ?Source, + /// The declarations of `bytes`, the file at `path`, outermost first + /// (syntax.analyzeSource's), the arena's. + declarations: *const fn (ctx: *const Ctx, path: []const u8, bytes: []const u8) error{OutOfMemory}![]const syntax.ContextDeclaration, + /// The two above's own. + host: *anyopaque, + /// A declaration above a hunk gets its `path:line` row too + /// (LocationsConfig's tslocations). + tslocations: bool, +}; + +/// A file's text, and its path as `dir` and the path named resolve. +pub const Source = struct { path: []const u8, bytes: []const u8 }; + /// The rows `content`, a diff, stacks to, for a pane in `dir`, with each -/// row's metadata (Output.fillRows). Text and rows are `p.gpa`'s; all else -/// is the step's scratch. -pub fn format(p: *Pardes, dir: []const u8, content: []const u8) !locations.Result { - const arena = p.scratch.allocator(); +/// row's metadata (Output.fillRows). Text and rows are `ctx.gpa`'s. +pub fn format(ctx: *const Ctx, dir: []const u8, content: []const u8) !locations.Result { + const arena = ctx.arena; const styles = try syntax.highlightDiff(arena, content, 0, content.len); - var out: Out = .{ .p = p, .text = .init(p.gpa) }; + var out: Out = .{ .gpa = ctx.gpa, .text = .init(ctx.gpa) }; errdefer out.deinit(); var walk: diff.Walk = .{}; var hunk: Hunk = .{}; @@ -46,7 +68,7 @@ pub fn format(p: *Pardes, dir: []const u8, content: []const u8) !locations.Resul // A `\ No newline` belongs to the line above, as delta shows it. .no_newline => {}, else => { - try flush(&out, &hunk, &source, dir); + try flush(ctx, &out, &hunk, &source, dir); switch (got.kind) { .hunk => hunk = .{ .path = walk.path(), @@ -69,9 +91,9 @@ pub fn format(p: *Pardes, dir: []const u8, content: []const u8) !locations.Resul } at = nl + 1; } - try flush(&out, &hunk, &source, dir); - const rows = try out.rows.toOwnedSlice(p.gpa); - errdefer locations.freeRows(p.gpa, rows); + try flush(ctx, &out, &hunk, &source, dir); + const rows = try out.rows.toOwnedSlice(ctx.gpa); + errdefer locations.freeRows(ctx.gpa, rows); return .{ .content = try out.text.toOwnedSlice(), .rows = rows, .anchor = null }; } @@ -105,13 +127,13 @@ fn gitContext(line: []const u8) []const u8 { } const Out = struct { - p: *Pardes, + gpa: std.mem.Allocator, text: std.Io.Writer.Allocating, rows: std.ArrayList(Row) = .empty, fn deinit(out: *Out) void { out.text.deinit(); - locations.freeRowList(out.p.gpa, &out.rows); + locations.freeRowList(out.gpa, &out.rows); } const Meta = struct { @@ -127,7 +149,7 @@ const Out = struct { fn row(out: *Out, text: []const u8, path: []const u8, meta: Meta) !void { try out.text.writer.writeAll(text); try out.text.writer.writeByte('\n'); - try locations.appendRow(out.p.gpa, &out.rows, .{ + try locations.appendRow(out.gpa, &out.rows, .{ .kind = meta.kind, .declaration = meta.declaration, .path = @constCast(path), @@ -153,7 +175,7 @@ const SourceMemo = struct { /// Where a +Diff of `content`, a diff in `dir`, stands: the directory its /// first file is found from (`dir` or one above it, as `findSource` looks), /// so its rows name their files as the diff does; `dir` when none is found. -pub fn sourceRoot(p: *Pardes, dir: []const u8, content: []const u8) []const u8 { +pub fn sourceRoot(ctx: *const Ctx, dir: []const u8, content: []const u8) []const u8 { var walk: diff.Walk = .{}; var lines = std.mem.splitScalar(u8, content, '\n'); const path = while (lines.next()) |line| { @@ -161,31 +183,27 @@ pub fn sourceRoot(p: *Pardes, dir: []const u8, content: []const u8) []const u8 { } else return dir; var base: []const u8 = dir; for (0..8) |_| { - if (locations.sourceText(p, p.scratch.allocator(), base, path) != null) return base; + if (ctx.source(ctx, base, path) != null) return base; base = std.Io.Dir.path.dirname(base) orelse return dir; } return dir; } -fn findSource(p: *Pardes, memo: *SourceMemo, dir: []const u8, path: []const u8) !void { +fn findSource(ctx: *const Ctx, memo: *SourceMemo, dir: []const u8, path: []const u8) !void { if (std.mem.eql(u8, memo.path, path)) return; - const arena = p.scratch.allocator(); + const arena = ctx.arena; memo.* = .{ .path = path }; // ponytail: eight directories up; a repository deeper than that under // its patch is looked for from the patch's own directory only. var base: []const u8 = dir; for (0..8) |_| { - if (locations.sourceText(p, arena, base, path)) |text| { + if (ctx.source(ctx, base, path)) |text| { memo.shown = if (base.ptr == dir.ptr) path else try std.Io.Dir.path.relativePosix(arena, "/", dir, text.path); var lines: std.ArrayList([]const u8) = .empty; var split = std.mem.splitScalar(u8, text.bytes, '\n'); while (split.next()) |line| try lines.append(arena, std.mem.trimEnd(u8, line, "\r")); memo.lines = lines.items; - var hit = p.locations_cache.get(p.tree_sitter_gpa, text.path, text.bytes, true, false) catch - locations.Cache.Hit{ .analysis = syntax.analyzeSource(arena, text.path, text.bytes, true, false) catch .{} }; - defer hit.deinit(p.tree_sitter_gpa); - // The cache's may go at its next use: kept for the section. - memo.declarations = try arena.dupe(syntax.ContextDeclaration, hit.analysis.declarations); + memo.declarations = try ctx.declarations(ctx, text.path, text.bytes); return; } base = std.Io.Dir.path.dirname(base) orelse return; @@ -251,12 +269,11 @@ fn heldAt(memo: *const SourceMemo, hunk: *const Hunk, comptime side: Side, start return .{ .held = held, .of = @max(of, 1) }; } -fn flush(out: *Out, hunk: *Hunk, memo: *SourceMemo, dir: []const u8) !void { +fn flush(ctx: *const Ctx, out: *Out, hunk: *Hunk, memo: *SourceMemo, dir: []const u8) !void { defer hunk.* = .{}; if (hunk.path.len == 0 or hunk.lines.items.len == 0) return; - const p = out.p; - const arena = p.scratch.allocator(); - try findSource(p, memo, dir, hunk.path); + const arena = ctx.arena; + try findSource(ctx, memo, dir, hunk.path); const disk = sideOnDisk(memo, hunk); const side = disk.side; // A line number of the hunk's, where the file has it now. @@ -287,7 +304,7 @@ fn flush(out: *Out, hunk: *Hunk, memo: *SourceMemo, dir: []const u8) !void { var row = declaration.start_line; while (row <= declaration.header_end_line and row < start_row) : (row += 1) { const at: @FieldType(Row, "at") = .{ .line = row + 1 }; - if (row == declaration.start_line and p.locations_config.tslocations) { + if (row == declaration.start_line and ctx.tslocations) { const label = try std.fmt.allocPrint(arena, "{s}:{d}", .{ shown, row + 1 }); try out.row(label, shown, .{ .kind = .context, .declaration = true, .at = at, .location_end = label.len, .code_start = label.len }); } @@ -574,13 +591,40 @@ fn annotate(arena: std.mem.Allocator, a: *const Alignment, minus_line: []const u } fn trimmedWidth(section: []const u8) usize { - return pardes.panes.File.displayWidth(std.mem.trim(u8, section, " \t")); + return @import("File.zig").displayWidth(std.mem.trim(u8, section, " \t")); } // ---- tests ---- const testing = std.testing; +/// A Ctx over the disk, as the editor's is without panes or a cache. +const TestCtx = struct { + arena_state: std.heap.ArenaAllocator, + ctx: Ctx, + + fn init(t: *TestCtx) void { + t.arena_state = .init(testing.allocator); + t.ctx = .{ .gpa = testing.allocator, .arena = t.arena_state.allocator(), .source = source, .declarations = declarations, .host = t, .tslocations = true }; + syntax.start(testing.allocator); + } + + fn deinit(t: *TestCtx) void { + syntax.stop(); + t.arena_state.deinit(); + } + + fn source(ctx: *const Ctx, dir: []const u8, path: []const u8) ?Source { + const full = std.Io.Dir.path.resolvePosix(ctx.arena, &.{ dir, path }) catch return null; + const bytes = std.Io.Dir.cwd().readFileAlloc(testing.io, full, ctx.arena, .limited(1 << 20)) catch return null; + return .{ .path = full, .bytes = bytes }; + } + + fn declarations(ctx: *const Ctx, path: []const u8, bytes: []const u8) error{OutOfMemory}![]const syntax.ContextDeclaration { + return (syntax.analyzeSource(ctx.arena, path, bytes, true, false) catch return &.{}).declarations; + } +}; + fn emphasised(line: HunkLine) ![]const u8 { var out: std.ArrayList(u8) = .empty; for (line.code, line.styles) |c, s| try out.append(testing.allocator, if (s & syntax.ground_emph != 0) c else '.'); @@ -631,8 +675,9 @@ test "delta's alignment: kitten to sitting, as align.rs has it" { } test "a diff stacks to a label a hunk and its lines, markers gone, tinted and stepped" { - const p = try Pardes.init(testing.allocator, .{ .tty_only = true }); - defer p.deinit(); + var t: TestCtx = undefined; + t.init(); + defer t.deinit(); const patch = \\diff --git a/nowhere/x.txt b/nowhere/x.txt \\--- a/nowhere/x.txt @@ -644,9 +689,9 @@ test "a diff stacks to a label a hunk and its lines, markers gone, tinted and st \\ tail \\ ; - const result = try format(p, "/pardes-surely-missing-dir", patch); - defer p.gpa.free(result.content); - defer locations.freeRows(p.gpa, result.rows); + const result = try format(&t.ctx, "/pardes-surely-missing-dir", patch); + defer testing.allocator.free(result.content); + defer locations.freeRows(testing.allocator, result.rows); try testing.expectEqualStrings("nowhere/x.txt:2\n section one\n keep\n-old value\n+new value\n tail\n", result.content); try testing.expectEqual(@as(usize, 6), result.rows.len); try testing.expectEqual(.match, result.rows[0].kind); @@ -664,8 +709,9 @@ test "a diff stacks to a label a hunk and its lines, markers gone, tinted and st test "a hunk the file has moved since is found where it went, inside its declaration" { if (!syntax.supportsPath("a.zig")) return error.SkipZigTest; - const p = try Pardes.init(testing.allocator, .{ .tty_only = true }); - defer p.deinit(); + var t: TestCtx = undefined; + t.init(); + defer t.deinit(); var tmp = testing.tmpDir(.{}); defer tmp.cleanup(); // Two lines more above it than the patch knows of. @@ -682,16 +728,17 @@ test "a hunk the file has moved since is found where it went, inside its declara \\ b(); \\ ; - const result = try format(p, dir, patch); - defer p.gpa.free(result.content); - defer locations.freeRows(p.gpa, result.rows); + const result = try format(&t.ctx, dir, patch); + defer testing.allocator.free(result.content); + defer locations.freeRows(testing.allocator, result.rows); try testing.expect(std.mem.indexOf(u8, result.content, "a.zig:3\n const S = struct {\na.zig:5 *\n") != null); try testing.expect(std.mem.indexOf(u8, result.content, "git's guess") == null); } test "a mailed patch keeps its headers, message and diffstat above its hunks" { - const p = try Pardes.init(testing.allocator, .{ .tty_only = true }); - defer p.deinit(); + var t: TestCtx = undefined; + t.init(); + defer t.deinit(); const patch = \\From 0123 Mon Sep 17 00:00:00 2001 \\Subject: [PATCH] change x @@ -709,12 +756,15 @@ test "a mailed patch keeps its headers, message and diffstat above its hunks" { \\+b \\ ; - const result = try format(p, "/pardes-surely-missing-dir", patch); - defer p.gpa.free(result.content); - defer locations.freeRows(p.gpa, result.rows); + const result = try format(&t.ctx, "/pardes-surely-missing-dir", patch); + defer testing.allocator.free(result.content); + defer locations.freeRows(testing.allocator, result.rows); try testing.expectEqualStrings("From 0123 Mon Sep 17 00:00:00 2001\nSubject: [PATCH] change x\n\nWhy it changed.\n---\n x.txt | 2 +-\n\nx.txt:1\n-a\n+b\n", result.content); } +const pardes = @import("pardes.zig"); +const Pardes = pardes.Pardes; + test "a .patch looked at opens its +Diff, and Diff goes to the text and back" { const p = try Pardes.init(testing.allocator, .{ .tty_only = true }); defer p.deinit(); @@ -755,8 +805,9 @@ test "a .patch looked at opens its +Diff, and Diff goes to the text and back" { test "a hunk edited since, beside siblings with its signature's tail, is found in its own function" { if (!syntax.supportsPath("a.rs")) return error.SkipZigTest; - const p = try Pardes.init(testing.allocator, .{ .tty_only = true }); - defer p.deinit(); + var t: TestCtx = undefined; + t.init(); + defer t.deinit(); var tmp = testing.tmpDir(.{}); defer tmp.cleanup(); // Three functions ending in one signature's tail; the patch is for the @@ -799,9 +850,9 @@ test "a hunk edited since, beside siblings with its signature's tail, is found i \\ c \\ ; - const result = try format(p, dir, patch); - defer p.gpa.free(result.content); - defer locations.freeRows(p.gpa, result.rows); + const result = try format(&t.ctx, dir, patch); + defer testing.allocator.free(result.content); + defer locations.freeRows(testing.allocator, result.rows); try testing.expect(std.mem.indexOf(u8, result.content, "a.rs:12\n fn three(\na.rs:15 *\n") != null); } -- cgit v1.3 From 4a33b8d2bd409d4a06205f28e0eb1b4cdaf49889 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 17 Nov 2026 00:51:40 -0300 Subject: hunks: the +Diff's editor side in one place: openDiff, showDiffText and diffSource move from Output.zig, the `Diff` word's body and PaneKind.diff's test from builtins.zig, lookCommit (as lookedAtCommit) and its test from look.zig; builtins.zig's Diff is its one registration (its doc, traits and `run = hunks.word`); the three open hooks a plumber's rules would replace are a call each, look.zig's `hunks.lookedAt` (a bare look at a .diff or .patch) and `hunks.lookedAtCommit` (a commit hash) and ninep/ctl.zig's `hunks.paged` (a +Pager filled with a diff), their conditions inside them; the diff language (diff.zig, syntax.zig's highlightDiff, look's diff-line address) stays where the languages are; code locality's far share 0.575 before and after (codeloc.py --compare); goldens unchanged Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- src/Output.zig | 84 ------------------------- src/builtins.zig | 14 ++--- src/hunks.zig | 185 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- src/locations.zig | 2 +- src/look.zig | 57 +---------------- src/ninep/ctl.zig | 12 +--- src/panes.zig | 2 +- 7 files changed, 191 insertions(+), 165 deletions(-) (limited to 'src/hunks.zig') diff --git a/src/Output.zig b/src/Output.zig index 3bcc3fa5..2e49ceb3 100644 --- a/src/Output.zig +++ b/src/Output.zig @@ -14,8 +14,6 @@ const lsp = @import("lsp/lsp.zig"); const look = @import("look.zig"); const locations = @import("locations.zig"); const layout = @import("layout.zig"); -const hunks = @import("hunks.zig"); -const diff = @import("diff.zig"); const Pane = panes.Pane; const File = panes.File; @@ -486,88 +484,6 @@ pub fn fillRows(p: *Pardes, id: usize, dir: []const u8, from: Origin, name: ?[]c return free; } -/// Diff: `content`, the diff at `path` (a file, a +Pager), stacked as a -/// diff viewer shows it (hunks.zig), in a +Diff where its files are found -/// (hunks.sourceRoot), placed by pane `id`, refilled when it is there. Its -/// arg names the diff (its base name, or its whole path when the +Diff -/// stands elsewhere), for Diff to go back to it; a commit's (`git show`, a -/// mailed patch) is named for it too, `+Diff-<12 hex>`, so each commit -/// keeps a +Diff of its own. The +Diff's id; NoHunks when there is none in -/// it. -pub fn openDiff(p: *Pardes, id: usize, path: []const u8, content: []const u8) !usize { - const dir = std.Io.Dir.path.dirname(path) orelse p.sessionDir(); - // Each file read is a site of the step's tape (fs.zig): a replica - // replays the authority's bytes and reads no disk of its own. - const Read = struct { - fn source(ctx: *const hunks.Ctx, from: []const u8, name: []const u8) ?hunks.Source { - const pp: *Pardes = @ptrCast(@alignCast(ctx.host)); - const text = locations.sourceText(pp, ctx.arena, from, name) orelse return null; - return .{ .path = text.path, .bytes = text.bytes }; - } - fn declarations(ctx: *const hunks.Ctx, name: []const u8, bytes: []const u8) error{OutOfMemory}![]const @import("syntax.zig").ContextDeclaration { - const pp: *Pardes = @ptrCast(@alignCast(ctx.host)); - var hit = pp.locations_cache.get(pp.tree_sitter_gpa, name, bytes, true, false) catch - locations.Cache.Hit{ .analysis = @import("syntax.zig").analyzeSource(ctx.arena, name, bytes, true, false) catch .{} }; - defer hit.deinit(pp.tree_sitter_gpa); - // The cache's may go at its next use: kept for the call. - return ctx.arena.dupe(@import("syntax.zig").ContextDeclaration, hit.analysis.declarations); - } - }; - const ctx: hunks.Ctx = .{ - .gpa = p.gpa, - .arena = p.scratch.allocator(), - .source = Read.source, - .declarations = Read.declarations, - .host = p, - .tslocations = p.locations_config.tslocations, - }; - const root = hunks.sourceRoot(&ctx, dir, content); - const result = try hunks.format(&ctx, root, content); - errdefer { - p.gpa.free(result.content); - locations.freeRows(p.gpa, result.rows); - } - var has_hunk = false; - for (result.rows) |row| has_hunk = has_hunk or row.kind == .match; - if (!has_hunk) return error.NoHunks; - const arg = if (std.mem.eql(u8, root, dir) or path.len > max_arg) std.Io.Dir.path.basename(path) else path; - var name_buf: [config.diff_buffer.len + 13]u8 = undefined; - const name = if (diff.commitHash(content)) |hash| - std.fmt.bufPrint(&name_buf, "{s}-{s}", .{ config.diff_buffer, hash[0..@min(hash.len, 12)] }) catch unreachable - else - null; - return fillRows(p, id, root, .{ .cmd = .Diff }, name, arg, result.content, result.rows, null); -} - -/// Diff on a +Diff: the diff it stacks, as text. A pane holding it -/// already (the newest: a +Pager folded under its +Diff unfolds) is -/// shown; else the file is opened as text. -pub fn showDiffText(p: *Pardes, id: usize, source: []const u8) void { - var newest: ?usize = null; - for (p.panes, 0..) |slot, i| { - const f = (slot orelse continue).file orelse continue; - if (!std.mem.eql(u8, f.path, source)) continue; - if (newest == null or p.panes[newest.?].?.serial < slot.?.serial) newest = i; - } - if (newest) |i| { - if (p.panes[i].?.collapsed) layout.toggleCollapse(p, i); - p.view().active = i; - return; - } - p.look_text = true; - defer p.look_text = false; - look.lookAt(p, id, source); -} - -/// The diff a +Diff stacks (openDiff's arg): its path. -pub fn diffSource(p: *Pardes, f: *const File.State) ?[]const u8 { - const o = f.output orelse return null; - if (!std.meta.eql(o.from, Origin{ .cmd = .Diff })) return null; - const arg = o.arg(); - if (arg.len > 0 and arg[0] == '/') return arg; - return std.Io.Dir.path.join(p.scratch.allocator(), &.{ std.Io.Dir.path.dirname(f.path) orelse "", arg }) catch null; -} - pub fn openJumps(p: *Pardes, id: usize) !void { var out: std.Io.Writer.Allocating = .init(p.gpa); errdefer out.deinit(); diff --git a/src/builtins.zig b/src/builtins.zig index 85bb6e44..bb91d0b0 100644 --- a/src/builtins.zig +++ b/src/builtins.zig @@ -74,8 +74,7 @@ pub const PaneKind = enum { .image => pane.addon != null, .picture => pane.addon != null or pane.isTerminal(), .program_colors => pane.isTerminal() or (pane.file != null and pane.file.?.pager), - .diff => if (pane.file) |f| pane.colorAlgo() == .diff or - (f.output != null and std.meta.eql(f.output.?.from, panes.Output.Origin{ .cmd = .Diff })) else false, + .diff => @import("hunks.zig").shows(pane), }; } @@ -1089,17 +1088,12 @@ pub const Filter = struct { }; /// Stack a diff's hunks as a diff viewer shows them, each under its place and the declarations around it, in a +Diff; on a +Diff, show the diff itself as text. +/// The diff viewer's one registration: its word and traits here, all else +/// its own (hunks.zig). pub const Diff = struct { pub const needs: PaneKind = .diff; pub const output: OutputTraits = .{ .name = config.diff_buffer, .steps = true, .locations = true }; - pub fn run(c: Ctx) void { - const f = &c.pane.file.?; - if (panes.Output.diffSource(c.p, f)) |source| return panes.Output.showDiffText(c.p, c.id, source); - _ = panes.Output.openDiff(c.p, c.id, f.path, f.content) catch |err| switch (err) { - error.NoHunks => c.p.reportFailure(c.id, "Diff: no hunk in it"), - else => c.p.reportError(c.id, "hunks", err), - }; - } + pub const run = @import("hunks.zig").word; }; /// Cycle the pane's input modes: terminals add raw tty mode to normal/insert. diff --git a/src/hunks.zig b/src/hunks.zig index 28fffa38..afd2ac9d 100644 --- a/src/hunks.zig +++ b/src/hunks.zig @@ -10,12 +10,17 @@ const diff = @import("diff.zig"); const syntax = @import("syntax.zig"); const locations = @import("locations.zig"); +const pardes = @import("pardes.zig"); +const Pardes = pardes.Pardes; +const Pane = pardes.Pane; +const Output = pardes.panes.Output; + const Row = locations.Row; /// What `format` takes of the editor it stacks for: its allocators, the /// files a diff names read as the editor reads them (in pardes an open /// pane's text, else the disk's, each read a site of the step's tape: -/// Output.openDiff), their declarations, and one setting. +/// openDiff), their declarations, and one setting. pub const Ctx = struct { /// The text and rows made, the caller's. gpa: std.mem.Allocator, @@ -594,6 +599,171 @@ fn trimmedWidth(section: []const u8) usize { return @import("File.zig").displayWidth(std.mem.trim(u8, section, " \t")); } +// ---- the +Diff in the editor ---- +// +// Its word (Diff), the open and the text it goes back to; and the three +// hooks the generic code calls, one call each (look.zig's bare look and +// commit look, ninep/ctl.zig's filled +Pager), which a plumber's rules +// would replace. + +/// The `Diff` word (builtins.zig registers it): on a +Diff, the diff it +/// stacks as text; on a diff, its hunks stacked in a +Diff. +pub fn word(c: pardes.builtins.Ctx) void { + const f = &c.pane.file.?; + if (diffSource(c.p, f)) |source| return showDiffText(c.p, c.id, source); + _ = openDiff(c.p, c.id, f.path, f.content) catch |err| switch (err) { + error.NoHunks => c.p.reportFailure(c.id, "Diff: no hunk in it"), + else => c.p.reportError(c.id, "hunks", err), + }; +} + +/// A pane the word works on: a diff (a .diff, a .patch, a +Pager holding +/// one) or a +Diff. +pub fn shows(pane: *const Pane) bool { + const f = pane.file orelse return false; + return pane.colorAlgo() == .diff or (f.output != null and std.meta.eql(f.output.?.from, Output.Origin{ .cmd = .Diff })); +} + +/// The hook of a bare look at a .diff or a .patch (look.zig's open): its +/// hunks stacked in a +Diff, which takes the keyboard as the file would; +/// false, for look to open it as text, when it is no such file, a place in +/// one, one with no hunk, or the text is what is asked (showDiffText). +pub fn lookedAt(p: *Pardes, id: usize, path: []const u8, at: pardes.look.Spot) bool { + if (p.look_text or at.line != 0 or !(std.mem.endsWith(u8, path, ".diff") or std.mem.endsWith(u8, path, ".patch"))) return false; + const bytes = pardes.filesystem.read(p, path) catch return false; + defer p.gpa.free(bytes); + p.view().active = openDiff(p, id, path, bytes) catch return false; + return true; +} + +/// The hook of a +Pager filled with a diff (ninep/ctl.zig's fillPager: +/// `git show`, difftui's patches): its hunks stacked in a +Diff in the +/// +Pager's place, the +Pager closed. The keyboard stays where it was, as +/// a page's. +pub fn paged(p: *Pardes, id: usize) void { + const f = &p.panes[id].?.file.?; + const keyboard = p.view().active; + if (openDiff(p, id, f.path, f.content)) |hid| { + // ponytail: the text is gone with it; Diff on the +Diff says no such file. + p.removePane(id, hid) catch |err| p.reportError(id, "pager", err); + } else |_| {} + if (p.panes[keyboard] != null) p.view().active = keyboard; +} + +/// The hook of a commit hash (7 to 40 hex digits, a letter and a digit +/// among them; look.zig's look at a word) looked at inside a git repository: `git show` it, paged into a +Pager, +/// which stacks its hunks in a +Diff (ctl.fillPager); the command pane +/// goes when it succeeds (Pane.commandDone). +// ponytail: a hex word that names no commit leaves git's error in a command pane, not a search; check the object first if that bites. +pub fn lookedAtCommit(p: *Pardes, id: usize, pane: *Pane, hash: []const u8) bool { + if (!isCommitHash(hash)) return false; + var dir = pardes.filesystem.localPath(Pardes.paneDir(pane)) orelse return false; + while (true) { + var buf: [4096]u8 = undefined; + const dot_git = std.fmt.bufPrint(&buf, "{s}/.git", .{dir}) catch return false; + if (pardes.exec.kindOf(dot_git) != null) break; + dir = std.Io.Dir.path.dirname(dir) orelse return false; + } + var line: [64]u8 = undefined; + const dst = pardes.exec.execute(p, id, std.fmt.bufPrint(&line, "git show {s}", .{hash}) catch return false) orelse return true; + if (p.panes[dst]) |c| c.command_pages = true; + return true; +} + +fn isCommitHash(hex: []const u8) bool { + if (hex.len < 7 or hex.len > 40) return false; + var digit = false; + var letter = false; + for (hex) |c| switch (c) { + '0'...'9' => digit = true, + 'a'...'f' => letter = true, + else => return false, + }; + return digit and letter; +} + +/// Diff: `content`, the diff at `path` (a file, a +Pager), stacked as a +/// diff viewer shows it (format), in a +Diff where its files are found +/// (sourceRoot), placed by pane `id`, refilled when it is there. Its +/// arg names the diff (its base name, or its whole path when the +Diff +/// stands elsewhere), for Diff to go back to it; a commit's (`git show`, a +/// mailed patch) is named for it too, `+Diff-<12 hex>`, so each commit +/// keeps a +Diff of its own. The +Diff's id; NoHunks when there is none in +/// it. +pub fn openDiff(p: *Pardes, id: usize, path: []const u8, content: []const u8) !usize { + const dir = std.Io.Dir.path.dirname(path) orelse p.sessionDir(); + // Each file read is a site of the step's tape (fs.zig): a replica + // replays the authority's bytes and reads no disk of its own. + const Read = struct { + fn source(ctx: *const Ctx, from: []const u8, name: []const u8) ?Source { + const pp: *Pardes = @ptrCast(@alignCast(ctx.host)); + const text = locations.sourceText(pp, ctx.arena, from, name) orelse return null; + return .{ .path = text.path, .bytes = text.bytes }; + } + fn declarations(ctx: *const Ctx, name: []const u8, bytes: []const u8) error{OutOfMemory}![]const syntax.ContextDeclaration { + const pp: *Pardes = @ptrCast(@alignCast(ctx.host)); + var hit = pp.locations_cache.get(pp.tree_sitter_gpa, name, bytes, true, false) catch + locations.Cache.Hit{ .analysis = syntax.analyzeSource(ctx.arena, name, bytes, true, false) catch .{} }; + defer hit.deinit(pp.tree_sitter_gpa); + // The cache's may go at its next use: kept for the call. + return ctx.arena.dupe(syntax.ContextDeclaration, hit.analysis.declarations); + } + }; + const ctx: Ctx = .{ + .gpa = p.gpa, + .arena = p.scratch.allocator(), + .source = Read.source, + .declarations = Read.declarations, + .host = p, + .tslocations = p.locations_config.tslocations, + }; + const root = sourceRoot(&ctx, dir, content); + const result = try format(&ctx, root, content); + errdefer { + p.gpa.free(result.content); + locations.freeRows(p.gpa, result.rows); + } + var has_hunk = false; + for (result.rows) |row| has_hunk = has_hunk or row.kind == .match; + if (!has_hunk) return error.NoHunks; + const arg = if (std.mem.eql(u8, root, dir) or path.len > Output.max_arg) std.Io.Dir.path.basename(path) else path; + var name_buf: [pardes.config.diff_buffer.len + 13]u8 = undefined; + const name = if (diff.commitHash(content)) |hash| + std.fmt.bufPrint(&name_buf, "{s}-{s}", .{ pardes.config.diff_buffer, hash[0..@min(hash.len, 12)] }) catch unreachable + else + null; + return Output.fillRows(p, id, root, .{ .cmd = .Diff }, name, arg, result.content, result.rows, null); +} + +/// Diff on a +Diff: the diff it stacks, as text. A pane holding it +/// already (the newest: a +Pager folded under its +Diff unfolds) is +/// shown; else the file is opened as text. +pub fn showDiffText(p: *Pardes, id: usize, source: []const u8) void { + var newest: ?usize = null; + for (p.panes, 0..) |slot, i| { + const f = (slot orelse continue).file orelse continue; + if (!std.mem.eql(u8, f.path, source)) continue; + if (newest == null or p.panes[newest.?].?.serial < slot.?.serial) newest = i; + } + if (newest) |i| { + if (p.panes[i].?.collapsed) pardes.layout.toggleCollapse(p, i); + p.view().active = i; + return; + } + p.look_text = true; + defer p.look_text = false; + pardes.look.lookAt(p, id, source); +} + +/// The diff a +Diff stacks (openDiff's arg): its path. +pub fn diffSource(p: *Pardes, f: *const pardes.panes.File.State) ?[]const u8 { + const o = f.output orelse return null; + if (!std.meta.eql(o.from, Output.Origin{ .cmd = .Diff })) return null; + const arg = o.arg(); + if (arg.len > 0 and arg[0] == '/') return arg; + return std.Io.Dir.path.join(p.scratch.allocator(), &.{ std.Io.Dir.path.dirname(f.path) orelse "", arg }) catch null; +} + // ---- tests ---- const testing = std.testing; @@ -762,9 +932,6 @@ test "a mailed patch keeps its headers, message and diffstat above its hunks" { try testing.expectEqualStrings("From 0123 Mon Sep 17 00:00:00 2001\nSubject: [PATCH] change x\n\nWhy it changed.\n---\n x.txt | 2 +-\n\nx.txt:1\n-a\n+b\n", result.content); } -const pardes = @import("pardes.zig"); -const Pardes = pardes.Pardes; - test "a .patch looked at opens its +Diff, and Diff goes to the text and back" { const p = try Pardes.init(testing.allocator, .{ .tty_only = true }); defer p.deinit(); @@ -888,3 +1055,13 @@ test "patch panes keep different commits and reuse only the same commit" { try testing.expectEqual(first, try Page.open(p, a)); try testing.expectEqualStrings(original, p.panes[first].?.file.?.content); } + +test "a commit hash is 7 to 40 lowercase hex digits with a letter and a digit" { + try std.testing.expect(isCommitHash("9bffa7041c")); + try std.testing.expect(isCommitHash("9bffa7041cd2e8a0b6b1f7c3e4d5a6b7c8d9e0f1")); + try std.testing.expect(!isCommitHash("9bffa7")); + try std.testing.expect(!isCommitHash("defaced")); + try std.testing.expect(!isCommitHash("1234567")); + try std.testing.expect(!isCommitHash("0x9bffa7041c")); + try std.testing.expect(!isCommitHash("9BFFA7041C")); +} diff --git a/src/locations.zig b/src/locations.zig index 3dc0412d..ca6b7a7d 100644 --- a/src/locations.zig +++ b/src/locations.zig @@ -1131,7 +1131,7 @@ test "rows read back from their text are the rows: +Search's, +Callstack's and + const callstack = try formatCallstack(p, dir, "a.zig:2:8 f\n└─ a.zig:3:9 a\n"); defer p.gpa.free(callstack.content); defer freeRows(p.gpa, callstack.rows); - const hid = try pardes.panes.Output.openDiff(p, 0, patch, "--- a.zig\n+++ a.zig\n@@ -2,3 +2,4 @@\n fn f() void {\n- a(\"x\");\n+ a(\"x y\");\n+ b();\n }\n"); + const hid = try @import("hunks.zig").openDiff(p, 0, patch, "--- a.zig\n+++ a.zig\n@@ -2,3 +2,4 @@\n fn f() void {\n- a(\"x\");\n+ a(\"x y\");\n+ b();\n }\n"); const stacked = p.panes[hid].?.file.?.location_rows; // A +Diff's rows carry styles with grounds: the codec is tried on them. var grounded = false; diff --git a/src/look.zig b/src/look.zig index ab77773f..115e3683 100644 --- a/src/look.zig +++ b/src/look.zig @@ -4,6 +4,7 @@ const builtin = @import("builtin"); const libc = std.c; const pardes = @import("pardes.zig"); const exec = @import("exec.zig"); +const hunks = @import("hunks.zig"); const config = @import("config.zig"); const diff = @import("diff.zig"); const platform_has_fs = filesystem.platform_has_fs; @@ -1089,7 +1090,7 @@ fn lookUnresolved(p: *Pardes, id: usize, pane: *Pane, trimmed: []const u8, text: // 9P is no keyboard input, and searches whatever the key mode. if (pane.addon != null or (pane.body.mode == .tty and !p.fs.serving)) return; if (text.len == 0) return; - if (lookCommit(p, id, pane, trimmed)) return; + if (hunks.lookedAtCommit(p, id, pane, trimmed)) return; if (pane.file != null) return lookWord(p, id, pane, text); p.word_look = true; defer p.word_look = false; @@ -1110,38 +1111,6 @@ fn lookUnresolved(p: *Pardes, id: usize, pane: *Pane, trimmed: []const u8, text: } } -/// A commit hash (7 to 40 hex digits, a letter and a digit among them) -/// looked at inside a git repository: `git show` it, paged into a +Pager, -/// which stacks its hunks in a +Diff (ctl.fillPager); the command pane -/// goes when it succeeds (Pane.commandDone). -// ponytail: a hex word that names no commit leaves git's error in a command pane, not a search; check the object first if that bites. -fn lookCommit(p: *Pardes, id: usize, pane: *Pane, word: []const u8) bool { - if (!isCommitHash(word)) return false; - var dir = filesystem.localPath(Pardes.paneDir(pane)) orelse return false; - while (true) { - var buf: [4096]u8 = undefined; - const dot_git = std.fmt.bufPrint(&buf, "{s}/.git", .{dir}) catch return false; - if (exec.kindOf(dot_git) != null) break; - dir = std.Io.Dir.path.dirname(dir) orelse return false; - } - var line: [64]u8 = undefined; - const dst = exec.execute(p, id, std.fmt.bufPrint(&line, "git show {s}", .{word}) catch return false) orelse return true; - if (p.panes[dst]) |c| c.command_pages = true; - return true; -} - -fn isCommitHash(word: []const u8) bool { - if (word.len < 7 or word.len > 40) return false; - var digit = false; - var letter = false; - for (word) |c| switch (c) { - '0'...'9' => digit = true, - 'a'...'f' => letter = true, - else => return false, - }; - return digit and letter; -} - /// Opens (or finds) `path` as Look would, `id`'s own pane when it is empty, /// and selects what `expr` addresses there from its dot. An address that /// does not evaluate moves nothing and says why (acme: no jump). @@ -1634,18 +1603,7 @@ pub fn lookAt(p: *Pardes, id: usize, operand_raw: []const u8) void { const before = v.active; var opened: ?usize = null; if (!focusPaneByPath(p, target.path, target.at)) { - // A .diff or .patch looked at bare: its hunks stacked in a - // +Diff, which takes the keyboard as the file would; one - // with none in it opens as text. - if (!p.look_text and target.at.line == 0 and - (std.mem.endsWith(u8, target.path, ".diff") or std.mem.endsWith(u8, target.path, ".patch"))) - if (filesystem.read(p, target.path)) |bytes| { - defer p.gpa.free(bytes); - if (panes.Output.openDiff(p, id, target.path, bytes)) |hid| { - v.active = hid; - return; - } else |_| {} - } else |_| {}; + if (hunks.lookedAt(p, id, target.path, target.at)) return; const free = p.freeSlot() orelse return p.reportError(id, "look", error.NoPaneSlots); const nt = panes.File.open(p, free, target.path, target.at.line) catch |err| return lookOpenFailed(p, id, target.path, err); @@ -1915,15 +1873,6 @@ test "a zero column after a path is found, in every spelling a look takes" { for ([_][]const u8{ "", ":3", ":3:1", ":3:2-5", ":3:2-5:7", ":30:10" }) |rest| try std.testing.expect(!zeroColumn(rest)); } -test "a commit hash is 7 to 40 lowercase hex digits with a letter and a digit" { - try std.testing.expect(isCommitHash("9bffa7041c")); - try std.testing.expect(isCommitHash("9bffa7041cd2e8a0b6b1f7c3e4d5a6b7c8d9e0f1")); - try std.testing.expect(!isCommitHash("9bffa7")); - try std.testing.expect(!isCommitHash("defaced")); - try std.testing.expect(!isCommitHash("1234567")); - try std.testing.expect(!isCommitHash("0x9bffa7041c")); - try std.testing.expect(!isCommitHash("9BFFA7041C")); -} test "Look hover waits without mutating the pane and input cancels it" { const delay = config.look_preview_delay_frames; diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index a72e7259..7bd586dc 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -718,17 +718,7 @@ pub fn fillPager(p: *Pardes, serial: u32, held: *std.ArrayList(u8)) error{OutOfM panes.File.setContent(p, f, page.text); f.pager_spans = page.spans; f.saved_revision = f.revision; - // A diff paged (`git show`, difftui's patches): its hunks stacked in a - // +Diff in the +Pager's place, the +Pager closed. The keyboard stays - // where it was, as a page's. - if (f.pager_diff) { - const keyboard = p.view().active; - if (panes.Output.openDiff(p, id, f.path, f.content)) |hid| { - // ponytail: the text is gone with it; Diff on the +Diff says no such file. - p.removePane(id, hid) catch |err| p.reportError(id, "pager", err); - } else |_| {} - if (p.panes[keyboard] != null) p.view().active = keyboard; - } + if (f.pager_diff) @import("../hunks.zig").paged(p, id); } /// The editor's step: the text of /pager opens closed unread goes in. diff --git a/src/panes.zig b/src/panes.zig index 29a9f051..1d1feb19 100644 --- a/src/panes.zig +++ b/src/panes.zig @@ -171,7 +171,7 @@ pub const Pane = struct { /// be printing to it, and a reuse would hang it up. command_pty: bool = false, /// Its child pages as a terminal's does (`pardes -`, a +Pager), not - /// through cat: Look's `git show` of a commit (look.lookCommit). + /// through cat: Look's `git show` of a commit (hunks.lookedAtCommit). command_pages: bool = false, /// The shell a terminal runs when it is not the configured one (`Term /// fish`), owned. -- cgit v1.3