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/Query.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/Query.zig')
| -rw-r--r-- | src/Query.zig | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/Query.zig b/src/Query.zig index c1a89164..4ae57691 100644 --- a/src/Query.zig +++ b/src/Query.zig @@ -2728,3 +2728,30 @@ test "a row's address is the shortest path a Look from the query pane resolves: } else return error.TestUnexpectedResult; } } + +test "a query row's address reaches every way a look arrives: an empty look written back to event and the whole row written to look, as the mouse on it" { + if (!filesystem.platform_has_fs) return; + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 120, .rows = 48 }); + defer p.deinit(); + const a = try testFileIn(p, &tmp, "a.txt", "zero\none needle\ntwo\nthree needle here\n"); + leader(p, "fg"); + typeKeys(p, "needle"); + settle(p); + const qid = queryPane(p).?; + const qp = p.panes[qid].?; + const f = &qp.file.?; + const at = std.mem.indexOf(u8, f.content, "\na.txt:4:7").? + 1; + const line = f.content[at..std.mem.indexOfScalarPos(u8, f.content, at, '\n').?]; + // an empty look written back, on the address: the row's address whole, + // its path as the row keeps it + try std.testing.expect(std.mem.endsWith(u8, @import("ninep/events.zig").expandAt(p, qp, f.content, at + 3, true, true), "/a.txt:4:7")); + // on its code: the word there + try std.testing.expectEqualStrings("three", @import("ninep/events.zig").expandAt(p, qp, f.content, at + line.len - "three needle here".len + 1, true, true)); + // the whole row written to the pane's look: the place + a.body.cur_row = 0; + const tree = @import("ninep/tree.zig"); + try std.testing.expectEqual(tree.Status.ok, @import("ninep/testing.zig").wr(p, tree.Node.of(qp.serial, .look), line).reply.status); + try std.testing.expectEqual(@as(i32, 3), a.body.cur_row); +} |
