diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-01 02:44:38 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 02:44:38 -0300 |
| commit | 43b75a3c79e204b758df8d361c213364dc4fe064 (patch) | |
| tree | 6c3b88a5824b573acc53a1f336138681f7c46bf9 /src/ninep | |
| parent | 3bddd662eac9a7829174f3c54b498bda84df1961 (diff) | |
| download | pardes-43b75a3c79e204b758df8d361c213364dc4fe064.tar.gz pardes-43b75a3c79e204b758df8d361c213364dc4fe064.zip | |
A look line's trailing colon is dropped, as a click leaves it off, and a look whose address fails never leaves the file it opened
`a.txt:2:3:`, as a compiler prints a place, failed as bad address
syntax, and still opened a.txt: the file was opened to read the
address in, and stayed when the address failed. The trailing colon is
now no part of the place, and a pane opened only to evaluate an address
that fails goes again, the miss said from the pane looked from.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/ninep')
| -rw-r--r-- | src/ninep/ctl.zig | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index 6326b1c0..9092a307 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -1852,6 +1852,36 @@ test "a bad setting value is quoted, so two different bad values log as two reco try testing.expect(!th.logHas(p, "(x2)")); } +test "a look line's trailing colon is dropped, and a look whose address fails never leaves its file open" { + const p = try withFile(testing.allocator, "x\n"); + defer p.deinit(); + var tmp = testing.tmpDir(.{}); + defer tmp.cleanup(); + try tmp.dir.writeFile(testing.io, .{ .sub_path = "a.txt", .data = "one\ntwo\nthree\n" }); + var dir_buf: [4096]u8 = undefined; + const dir = dir_buf[0..try tmp.dir.realPath(testing.io, &dir_buf)]; + var line: [4200]u8 = undefined; + const count = struct { + fn of(pp: *Pardes) usize { + var n: usize = 0; + for (pp.panes) |slot| n += @intFromBool(slot != null); + return n; + } + }.of; + const before = count(p); + // Failing addresses: nothing opened, the write still answered. + inline for ([_][]const u8{ "{s}/a.txt:/nomatch/\n", "{s}/a.txt:9:\n" }) |fmt| { + _ = wr(p, root_look, try std.fmt.bufPrint(&line, fmt, .{dir})); + try testing.expectEqual(before, count(p)); + } + // `a.txt:2:3:` is `a.txt:2:3`: it opens there. + try testing.expectEqual(Status.ok, wr(p, root_look, try std.fmt.bufPrint(&line, "{s}/a.txt:2:3:\n", .{dir})).reply.status); + try testing.expectEqual(before + 1, count(p)); + const opened = p.panes[p.active].?; + try testing.expect(std.mem.endsWith(u8, opened.file.?.path, "/a.txt")); + try testing.expectEqual(@as(i32, 1), opened.body.cur_row); +} + test "a bare :N or :N:M look addresses the pane itself, from its look, the root's and event write-back" { const p = try withFile(testing.allocator, "alpha\nbeta\ngamma\n"); defer p.deinit(); |
