summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/look.zig28
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);
+}