diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-23 11:37:50 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-23 11:54:56 -0300 |
| commit | 2da0bb429eb5667acc8be70f81196dbc8d47187f (patch) | |
| tree | 96014f22f97d32cb11cb77710a55c7fec6fd99c3 /core/hunks.zig | |
| parent | d4445d6d818e829a944a6ee37c43b7c5f1178237 (diff) | |
| download | pardes-2da0bb429eb5667acc8be70f81196dbc8d47187f.tar.gz pardes-2da0bb429eb5667acc8be70f81196dbc8d47187f.zip | |
changes layer: a Look on a jj change's id opens its patch, its header and whole message at the top, and a Look on a ghost row looks at its word as anywhere (the user's rulings of 2026-11-23: all text is text; a patch of one change opens with its metadata): a word of k to z letters had no meaning to a Look (searched), `Diff` took only a git hash, and a B3 on a ghost row was a button of its own (`lookGhost` opened the line in the revision it came from); now `Diff <change> [path[:line]]` (core/jj.zig `diffChange`, from hunks.zig's word) runs `jj show --git -r change_id(<change>)` in the pane's repository (on the tape, as `At`'s `jj file show`), stacks it in the change's own `+Diff-<commit>` with jj's header above the hunks (Commit ID, Change ID, Author, Committer, the whole message) and puts the cursor on `path`'s row for `line` (that file's first row without one, the top without a place; a second Look moves the open one); a plumbing rule sends a change id looked at in any pane (eight to thirty-two letters k to z, as `jj log` writes them: four would name a change by accident too often) to `Diff`, which declines a word that names no change, so it is searched as before; a B3 on a ghost row looks at the word under it (`wordAt`, then the regular `look.lookAt`), and on a description's id runs `Diff <id> <path>:<line>` with the line of that change's last hunk in this file, the text a user could type; tests: "a Look on a change's id opens its patch ..." (B3 on mid's description id in a terminal and a window: a `+Diff-` pane, its first lines jj's header, ` mid` in it, the cursor on a.zig:4; the same typed with a.zig:2; `Look <cut's id>` from the file: cut's patch at its top; `Look zzzzzzzz`: no patch), the ghost-row test's Look now asserts a B3 on `c();`'s ghost row is what `Look c` does (no revision opens), and hunks.zig's "a log of several changes keeps each one's header and whole message above its own hunks" (git log -p: each commit's header above its own hunks: it passed on the base: the format keeps them); core-test 927/1091 (164 skipped), shell-test 1133/1136 (3 skipped)
Co-Authored-By: Claude Opus <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/hunks.zig')
| -rw-r--r-- | core/hunks.zig | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/core/hunks.zig b/core/hunks.zig index bee06cc2..e109b788 100644 --- a/core/hunks.zig +++ b/core/hunks.zig @@ -701,7 +701,9 @@ fn trimmedWidth(ctx: *const Ctx, section: []const u8) usize { /// (a .diff, a .patch: relative to the pane's directory), its hunks /// stacked so; with a revision (7 to 40 lowercase hex digits, a letter and /// a digit among them), `git show` of it, paged into a +Pager that stacks -/// its hunks (ctl.fillPager), run in the pane's git work tree. A plumbing +/// its hunks (ctl.fillPager), run in the pane's git work tree; with a jj +/// change (`Diff wrnnmymq [path[:line]]`: jj.diffChange), its patch, header +/// and all, the cursor at that place in it. A plumbing /// rule's Diff that cannot (no hunk, no work tree) declines, saying /// nothing (Pardes.plumb_declined), and the look looks itself. pub fn word(c: pardes.builtins.Ctx) void { @@ -731,6 +733,9 @@ pub fn word(c: pardes.builtins.Ctx) void { if (p.panes[dst]) |cp| cp.command_pages = true; return; } + // A jj change (its letters k to z), with a place in its patch to stand at. + if (@import("jj.zig").diffChange(p, c.id, arg)) return; + if (@import("jj.zig").isChangeId(arg[0 .. std.mem.indexOfAny(u8, arg, " \t") orelse arg.len])) return declined(p, c.id, "Diff: no such change"); var buf: [4096]u8 = undefined; const path = if (arg[0] == '/') arg else std.fmt.bufPrint(&buf, "{s}/{s}", .{ std.mem.trimEnd(u8, Pardes.paneDir(c.pane), "/"), arg }) catch arg; const bytes = pardes.filesystem.read(p, path) catch |err| { @@ -1072,6 +1077,48 @@ 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); } +test "a log of several changes keeps each one's header and whole message above its own hunks: git log -p, jj show's header" { + var t: TestCtx = undefined; + t.init(); + defer t.deinit(); + const log = + \\commit 1111111111111111111111111111111111111111 + \\Author: A <a@a> + \\Date: Mon Nov 23 10:00:00 2026 -0300 + \\ + \\ second + \\ + \\ its body, a line + \\ + \\diff --git a/x.txt b/x.txt + \\index 1..2 100644 + \\--- a/x.txt + \\+++ b/x.txt + \\@@ -1 +1 @@ + \\-b + \\+c + \\ + \\commit 2222222222222222222222222222222222222222 + \\Author: A <a@a> + \\Date: Mon Nov 23 09:00:00 2026 -0300 + \\ + \\ first + \\ + \\diff --git a/x.txt b/x.txt + \\index 0..1 100644 + \\--- a/x.txt + \\+++ b/x.txt + \\@@ -1 +1 @@ + \\-a + \\+b + \\ + ; + const result = try paneResult(testing.allocator, try format(&t.ctx, "/pardes-surely-missing-dir", log)); + defer testing.allocator.free(result.content); + defer locations.freeRows(testing.allocator, result.rows); + try testing.expectEqualStrings("commit 1111111111111111111111111111111111111111\nAuthor: A <a@a>\nDate: Mon Nov 23 10:00:00 2026 -0300\n\n second\n\n its body, a line\n\nx.txt:1\n-b\n+c\n\ncommit 2222222222222222222222222222222222222222\nAuthor: A <a@a>\nDate: Mon Nov 23 09:00:00 2026 -0300\n\n first\n\nx.txt:1\n-a\n+b\n", result.content); +} + 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(); |
