summaryrefslogtreecommitdiff
path: root/src/exec.zig
diff options
context:
space:
mode:
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;