diff options
Diffstat (limited to 'src/exec.zig')
| -rw-r--r-- | src/exec.zig | 12 |
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; |
