diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-01 02:52:43 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 02:52:43 -0300 |
| commit | 0f5773256072b08a1ec294fa63822f63eb6a429b (patch) | |
| tree | f1aa96433911abe340cd141fe87a7fde27ed7e8f /src/ninep/pane.zig | |
| parent | 083167d5b6bc403395f18ddb5e07a2743bb2632f (diff) | |
| download | pardes-0f5773256072b08a1ec294fa63822f63eb6a429b.tar.gz pardes-0f5773256072b08a1ec294fa63822f63eb6a429b.zip | |
addr, dot and limit on a pane with no text, a terminal, an image or a PDF, are refused alike: "this pane has no text to address"
A terminal took an addr write and evaluated it over nothing, saying
"bad address syntax" or "address out of range" by the expression, while
dot refused it as no text at all. A range file of a pane with no text
now refuses every write the same way, before the expression is read.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/ninep/pane.zig')
| -rw-r--r-- | src/ninep/pane.zig | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/ninep/pane.zig b/src/ninep/pane.zig index 9aada3ee..47fdd755 100644 --- a/src/ninep/pane.zig +++ b/src/ninep/pane.zig @@ -819,6 +819,8 @@ fn pairOf(text: []const u8) ?State.Range { return .{ .q0 = q0, .q1 = q1 }; } +pub const e_no_text_address = "this pane has no text to address"; + pub const e_addr_failed = "no address: the last one written to addr failed"; /// A range file takes an address expression, or that pair of offsets. One @@ -826,6 +828,9 @@ pub const e_addr_failed = "no address: the last one written to addr failed"; /// regexp`, `address out of range`, `bad regular expression`, `addresses /// out of order`. fn writeRange(req: Req, pane: *Pane, file: PaneFile) Reply { + // A terminal, an image or a PDF has no text an address names: refused + // alike for addr, dot and limit, before the expression is read. + if (fileOf(pane) == null) return tree.failText(req.tag, E.INVAL, e_no_text_address); const pf = &pane.fs; const text = bodyOf(pane); clampAddr(pf, text.len); @@ -868,10 +873,7 @@ fn writeRange(req: Req, pane: *Pane, file: PaneFile) Reply { }, .limit => pf.limit = range, // Setting dot scrolls to it, which is the whole of acme's `show`. - .dot => { - if (fileOf(pane) == null) return tree.failText(req.tag, E.INVAL, e_no_text); - setDot(pane, range); - }, + .dot => setDot(pane, range), else => unreachable, } return .{ .tag = req.tag, .written = @intCast(req.data.len) }; |
