diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-29 01:40:00 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 00:12:15 -0300 |
| commit | 0493ed9c6e2af1c16b40a685efdb67881ac87570 (patch) | |
| tree | c4716f1c3a6b91b2037b5bbbe29db39793b83be5 | |
| parent | 3f017863e08208119859f9362a5c633ac39d4316 (diff) | |
| download | pardes-0493ed9c6e2af1c16b40a685efdb67881ac87570.tar.gz pardes-0493ed9c6e2af1c16b40a685efdb67881ac87570.zip | |
A look at file:/re/ on an open pane goes on from its dot, and a miss leaves it
Look's clean start cleared the active pane's selection before the address
read the dot, so the root look's file:/re/ always found the same match, a
miss collapsed the dot to a caret, and dumps kept the collapsed dot. A pane
already open on the path is now addressed where it stands.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
| -rw-r--r-- | src/look.zig | 10 | ||||
| -rw-r--r-- | src/ninep/ctl.zig | 17 |
2 files changed, 26 insertions, 1 deletions
diff --git a/src/look.zig b/src/look.zig index 542b1b63..9dfd912f 100644 --- a/src/look.zig +++ b/src/look.zig @@ -1237,7 +1237,15 @@ fn lookAddress(p: *Pardes, id: usize, path: []const u8, expr: []const u8) void { const ninep_pane = @import("ninep/pane.zig"); const Addr = @import("ninep/addr.zig").Addr; var target = id; - if (path.len > 0) { + // A pane already open on the path is evaluated where it stands: Look's + // own clean start would collapse its dot (and the looker's) before the + // address ever read it, so `f:/re/` again would find the same match. + var realbuf: [4096]u8 = undefined; + const open: ?usize = if (path.len == 0) null else switch (resolveLookTarget(p, id, path, &realbuf)) { + .pane => |t| if (t.id < MAX_PANES and p.panes[t.id] != null) t.id else null, + else => null, + }; + if (open) |o| target = o else if (path.len > 0) { const before = p.active; lookAt(p, id, path); target = p.active; diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index 2fdc47cc..caa3f009 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -980,6 +980,23 @@ test "a look takes acme's :addr and file:addr, and a miss changes nothing" { try testing.expectStringStartsWith(p.panes[0].?.msg[0..p.panes[0].?.msg_len], "Look: "); } +test "the root look's file:/re/ goes on from the dot, and a miss leaves the dot as it was" { + const gpa = testing.allocator; + const p = try withFile(gpa, "foo x foo y\nfoo\n"); + defer p.deinit(); + const dot = Node.of(serialOf(p), .dot); + const root = @intFromEnum(tree.TopFile.look); + var line: [256]u8 = undefined; + const path = p.panes[0].?.file.?.path; + const again = try std.fmt.bufPrint(&line, "{s}:/foo/\n", .{path}); + for ([_][]const u8{ " 0 3 ", " 6 9 ", " 12 15 ", " 0 3 " }) |want| { + try testing.expectEqual(Status.ok, wr(p, root, again).reply.status); + try testing.expectEqualStrings(want, rd(p, dot, 0, 64).bytes); + } + try testing.expectEqual(Status.ok, wr(p, root, try std.fmt.bufPrint(&line, "{s}:/zzqq/\n", .{path})).reply.status); + try testing.expectEqualStrings(" 0 3 ", rd(p, dot, 0, 64).bytes); +} + test "exec runs a builtin at the pane and records the pane it acted on" { const gpa = testing.allocator; const p = try withFile(gpa, "Msg fs-ran\n"); |
