summaryrefslogtreecommitdiff
path: root/src/exec.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-30 22:58:16 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:17 -0300
commitc27222be8ba77a3a6bdda16978f3001510bde055 (patch)
tree46e709eba262af80b516ade483d210400a09455f /src/exec.zig
parent4f65855f372186406f4e48708ec3d5eb9aceb6d3 (diff)
downloadpardes-c27222be8ba77a3a6bdda16978f3001510bde055.tar.gz
pardes-c27222be8ba77a3a6bdda16978f3001510bde055.zip
One diff-aware expansion for a click, a 9P whole-line look and an empty event write-back; a blank context line resolves to its path:line
The mouse expanded a diff line by its kind (a header or a hunk line's prefix to the line's address, a hunk line's code to words), but an empty look written back to event used the plain word expansion, so ML on a `+` took nothing, and a 9P look of a blank context line (` `) was refused as whitespace. look.diffClick is now the one answer: the mouse, the whole-line look and the event write-back all ask it, and a blank context line is a line like any other. A test asks all three on each kind of line. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/exec.zig')
-rw-r--r--src/exec.zig21
1 files changed, 7 insertions, 14 deletions
diff --git a/src/exec.zig b/src/exec.zig
index 104e3b4d..e15ad12c 100644
--- a/src/exec.zig
+++ b/src/exec.zig
@@ -176,21 +176,14 @@ pub fn pointerOperand(p: *Pardes, pane: *Pane, clicked: Pane.Sel) PointerOperand
// 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: {
- const lines = look.diffLines(p, pane) orelse break :diff;
- const at: usize = @intCast(row);
- if (at >= lines.len) break :diff;
- const line = lines[at];
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) {
- word_from = @intFromBool(line.len > 0 and std.mem.indexOfScalar(u8, "+- ", line[0]) != null);
- break :diff;
- },
- else => {},
- }
+ const at: usize = @intCast(row);
+ const click = look.diffClick(p, pane, at, @intCast(@max(0, col)), &address_buf) orelse break :diff;
+ const address = click.address orelse {
+ word_from = click.word_from;
+ break :diff;
+ };
+ const line = (look.diffLines(p, pane) orelse break :diff)[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;