summaryrefslogtreecommitdiff
path: root/src/exec.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-30 21:38:57 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:17 -0300
commit988b288b870dd0165f09b991839c2c37fcd3fd62 (patch)
tree6552dc29f322c6ec6ee89b3ffdcc811389305e27 /src/exec.zig
parent68dd567218505838814d73473460a0c0ff8e97b3 (diff)
downloadpardes-988b288b870dd0165f09b991839c2c37fcd3fd62.tar.gz
pardes-988b288b870dd0165f09b991839c2c37fcd3fd62.zip
A diff line looks up the path and line it names, as any look does
The look on a diff line was its own resolver: a walk up to .git/.jj from the diff's directory, its own "no such file here" and "deleted by this diff". A review tool's cached patch, in no repository, missed every file though the session's terminals sat in the checkout. Now a diff line only expands and transforms. Its expansion (what the hover shows) is the whole line for a header, a `@@` line, or a hunk line pointed at on its prefix, and its text is the look address the line names (look.diffAddress): `path` for `diff --git`/`---`/`+++`, `path:c` for `@@ -a,b +c,d @@`, `path:N` for a hunk line's new line (a removed line's, the new line now where it was). That text goes through the regular look exactly as if selected by hand: same resolution, placement and errors. A 9P look of a whole diff line takes the same transform. Kept: the line classification, hunk arithmetic, git prefix stripping and timestamp cutting (diff.zig). Gone: the repo-root walk, its messages, Target.old_side and deletesAhead, and the click's row stash (Pardes.diff_look). A test compares a B3 on a cached patch's line with a look of the hand-selected `entry/src/entry.rs:2` in the same session. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/exec.zig')
-rw-r--r--src/exec.zig12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/exec.zig b/src/exec.zig
index c673aab2..ea20f969 100644
--- a/src/exec.zig
+++ b/src/exec.zig
@@ -170,8 +170,9 @@ pub fn pointerOperand(p: *Pardes, pane: *Pane, clicked: Pane.Sel) PointerOperand
return result;
}
// In a diff, a file or hunk header, and a hunk line pointed at on its
- // `+`/`-`/` ` prefix, are looked at whole: the place the line names
- // (look.diffLook). A hunk line's code is words, looked at as ever:
+ // `+`/`-`/` ` prefix, expand to the whole line (the hover shows it) and
+ // the look is of the address it names (look.diffAddress), a regular
+ // look from there. A hunk line's code is words, looked at as ever:
// the code's, the prefix never one of them.
var word_from: usize = 0;
if (clicked.r0 >= pane.tag_rows and clicked.r0 == clicked.r1 and clicked.c0 == clicked.c1 and row >= 0) diff: {
@@ -179,7 +180,9 @@ pub fn pointerOperand(p: *Pardes, pane: *Pane, clicked: Pane.Sel) PointerOperand
const at: usize = @intCast(row);
if (at >= lines.len) break :diff;
const line = lines[at];
- const target = @import("diff.zig").targetAt(lines, at, pane.file == null) orelse break :diff;
+ var address_buf: [4096 + 32]u8 = undefined;
+ const address = look.diffAddress(pane, lines, at, &address_buf) orelse break :diff;
+ const target = @import("diff.zig").targetAt(lines, at, pane.file == null).?;
const on_prefix = col == 0 and line.len > 0 and std.mem.indexOfScalar(u8, "+- ", line[0]) != null;
switch (target.kind) {
.context, .added, .removed => if (!on_prefix) {
@@ -188,8 +191,7 @@ pub fn pointerOperand(p: *Pardes, pane: *Pane, clicked: Pane.Sel) PointerOperand
},
else => {},
}
- result.text = line;
- p.diff_look = .{ .serial = pane.serial, .row = at };
+ result.text = p.scratch.allocator().dupe(u8, address) catch break :diff;
const hi = std.math.cast(i32, line.len) orelse return result;
if (hi == 0) return result;
var expanded = clicked;