diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-17 00:39:47 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-17 12:15:01 -0300 |
| commit | dd5aa28c89e2ca31a4cd806d6087ce4ac52398fc (patch) | |
| tree | 2c79f9311d7dc2b7ef833257cfe260a631496146 /src/exec.zig | |
| parent | d7b3d57ed0ba649f01559356fbf2bf89561990ca (diff) | |
| download | pardes-dd5aa28c89e2ca31a4cd806d6087ce4ac52398fc.tar.gz pardes-dd5aa28c89e2ca31a4cd806d6087ce4ac52398fc.zip | |
look: one row address, look.rowAddressAt(pane, row, col): the address a row's producer gave it (a query pane's row on its address, Query.rowAddress) else the one the pane's language reads in the line (a diff's: diffClickIn), with where the row's words start and the address's text; the mouse (exec.operandAt), an empty look written back to `event` (events.expandAt) and a whole line written to `look` (look.lineAddress, was diffLineAddress) each ask it once, where the mouse asked Query.rowAddress and diffClick in turn and the other two asked the diff alone; so a query pane's gutter look reaches events and 9P too (the behaviour change, in the changelog); test: a query row's address from an event written back and from its whole line written to look, its code still words; the diff's look tests and goldens unchanged
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'src/exec.zig')
| -rw-r--r-- | src/exec.zig | 44 |
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; } |
