diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-25 05:57:09 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-25 05:57:09 -0300 |
| commit | 44356b5f12dd6700e3b11c1014fdbe6e9a8e9e23 (patch) | |
| tree | 6e6c61289d59adb5c2dd42f00095f7e4e84e517d /core | |
| parent | 18043e845b39ac63dfe4416787e5cf6476ce8434 (diff) | |
| download | pardes-44356b5f12dd6700e3b11c1014fdbe6e9a8e9e23.tar.gz pardes-44356b5f12dd6700e3b11c1014fdbe6e9a8e9e23.zip | |
look: a Look at a question's answer word answers it, as an Exec does (walk UI P3 item 6, C's leftover "B3 on answer words", SPEC §10.2 "Answers are clickable", DESIGN A15): the asking tag (`changed on disk ▸ r Reload k Keep mine d Diff`) answered B2 on `Reload` (exec.execute's Messages.answerWord) but B3, a click's Look, searched the body for the word; look.lookAt asks Messages.answerWord first, on the pane the question waits on, as execute does; TEST FIRST: look.zig "a Look at a question's answer word in its pane answers it, as an Exec does: B3 on Reload reads the file again"; core-test 1065/1235 (170 skipped), behaviour-test 280/280
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
Diffstat (limited to 'core')
| -rw-r--r-- | core/look.zig | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/core/look.zig b/core/look.zig index 21043250..0b42b603 100644 --- a/core/look.zig +++ b/core/look.zig @@ -1609,6 +1609,9 @@ fn lookOpenFailed(p: *Pardes, id: usize, path: []const u8, err: anyerror) void { pub fn lookAt(p: *Pardes, id: usize, operand_raw: []const u8) void { const v = p.view(); const pane = p.panes[id] orelse return; + // A question's answer word on the pane it waits on, Looked at (a click, + // B3 on `Reload` in its tag): answered, as Exec answers it. + if (pardes.Messages.answerWord(p, id, operand_raw)) return; // `~/x`, `~/x:12`, `~/x:/re/`: home, before anything reads the text. // Anything else as written: a look of ` return x` is of those blanks // too (the path, address and command readings below trim for @@ -2960,3 +2963,28 @@ test "Plumb: a commit hash looked at in a git work tree is git show's, paged; ou }; try std.testing.expect(paged); } + +test "a Look at a question's answer word in its pane answers it, as an Exec does: B3 on Reload reads the file again" { + const p = try Pardes.init(std.testing.allocator, .{ .cols = 120, .rows = 20 }); + defer p.deinit(); + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "c.zig", .data = "one\n" }); + var dir: [4096]u8 = undefined; + const path = try std.fmt.allocPrint(std.testing.allocator, "{s}/c.zig", .{dir[0..try tmp.dir.realPath(std.testing.io, &dir)]}); + defer std.testing.allocator.free(path); + const pane = try p.setTestFile("one\n"); + const id = p.view().active; + p.gpa.free(pane.file.?.path); + pane.file.?.path = try p.gpa.dupe(u8, path); + pane.file.?.saved_hash = panes.File.fileHash(&pane.file.?); + for ([_]u21{ 'G', 'o', 't', 'w', 'o', Key.escape }) |cp| p.update(.{ .key = .{ .cp = cp } }); + const disk = "zero\none\n"; + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "c.zig", .data = disk }); + p.update(.{ .file_changed = .{ .pane = .at(id), .bytes = disk } }); + try std.testing.expect(p.messages.waiting(pane) != null); + lookAt(p, id, "Reload"); + while (p.nextEffect()) |_| {} + try std.testing.expect(p.messages.waiting(pane) == null); + try std.testing.expectEqualStrings(disk, p.panes[id].?.file.?.content); +} |
