summaryrefslogtreecommitdiff
path: root/src/exec.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/exec.zig')
-rw-r--r--src/exec.zig44
1 files changed, 15 insertions, 29 deletions
diff --git a/src/exec.zig b/src/exec.zig
index df578d08..be8dc46b 100644
--- a/src/exec.zig
+++ b/src/exec.zig
@@ -165,44 +165,30 @@ pub fn operandAt(p: *Pardes, pane: *Pane, clicked: Pane.Sel, borrow: bool, for_l
return result;
}
}
- // In a diff, a file or hunk header, and a hunk line pointed at on its
- // `+`/`-`/` ` 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.
- // A query pane's row pointed at on its gutter (its line number): the
- // look is of the row's address (Query.rowAddress), as a +Diff line's
- // prefix is its place; the row's code is words, looked at as ever.
- if (for_look and pane.query != null and clicked.r0 >= pane.tag_rows and clicked.r0 == clicked.r1 and clicked.c0 == clicked.c1 and row >= 0 and col >= 0) gutter: {
- var address_buf: [4096 + 32]u8 = undefined;
- const address = panes.Query.rowAddress(pane, @intCast(row), @intCast(col), &address_buf) orelse break :gutter;
- const meta = pane.file.?.location_rows[@intCast(row)];
- result.text = p.scratch.allocator().dupe(u8, address) catch break :gutter;
- result.file_word = .{ .row = row, .lo = 0, .hi = @intCast(meta.location_end) };
- const expanded = fileWordCells(pane, clicked, row, 0, @intCast(meta.location_end)) orelse return result;
- result.preview = expanded;
- result.expanded = expanded;
- return result;
- }
+ // A row that names an address (look.rowAddressAt), pointed at on it: a
+ // query pane's row on its address (its gutter), a diff's file or hunk
+ // header anywhere, a hunk line on its `+`/`-`/` ` prefix. It expands
+ // to the address's text (the hover shows it) and the look is of the
+ // address, a regular look from there. A row's code is words, looked at
+ // as ever: the code's, the prefix never one of them. A click left of a
+ // query pane's text is no part of its row.
var word_from: usize = 0;
- if (for_look and clicked.r0 >= pane.tag_rows and clicked.r0 == clicked.r1 and clicked.c0 == clicked.c1 and row >= 0) diff: {
+ if (for_look and clicked.r0 >= pane.tag_rows and clicked.r0 == clicked.r1 and clicked.c0 == clicked.c1 and row >= 0 and (col >= 0 or pane.query == null)) row_address: {
var address_buf: [4096 + 32]u8 = undefined;
- 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 got = look.rowAddressAt(p, pane, @intCast(row), @intCast(@max(0, col)), &address_buf) orelse break :row_address;
+ const address = got.address orelse {
+ word_from = got.word_from;
+ break :row_address;
};
- 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;
+ result.text = p.scratch.allocator().dupe(u8, address) catch break :row_address;
+ const hi = std.math.cast(i32, got.end) orelse return result;
if (hi == 0) return result;
var expanded = clicked;
if (pane.file != null) {
result.file_word = .{ .row = row, .lo = 0, .hi = hi };
expanded = fileWordCells(pane, clicked, row, 0, hi) orelse return result;
} else {
- const shown = if (raw) raw_line else line;
+ const shown = if (raw) raw_line else got.line;
expanded.c0 = 0;
expanded.c1 = @as(i32, @intCast(panes.File.rawDisplayCol(shown, shown.len))) - 1;
}