diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Query.zig | 2 | ||||
| -rw-r--r-- | src/builtins.zig | 79 | ||||
| -rw-r--r-- | src/edit_cmd.zig | 10 | ||||
| -rw-r--r-- | src/exec.zig | 52 | ||||
| -rw-r--r-- | src/lsp/Ask.zig | 18 | ||||
| -rw-r--r-- | src/ninep/ctl.zig | 43 | ||||
| -rw-r--r-- | src/ninep/events.zig | 15 | ||||
| -rw-r--r-- | src/ninep/tree.zig | 2 |
8 files changed, 111 insertions, 110 deletions
diff --git a/src/Query.zig b/src/Query.zig index 0220a983..abcf147e 100644 --- a/src/Query.zig +++ b/src/Query.zig @@ -1116,7 +1116,7 @@ fn makeNameRows(p: *Pardes, id: usize) !void { meta.path = @constCast(if (t.path.len > 0 and t.path[0] == '/') t.path else std.fmt.bufPrint(&pathbuf, "{s}/{s}", .{ std.mem.trimEnd(u8, dir, "/"), t.path }) catch t.path); meta.at = t.at; }, - .panes => meta.path = @constCast(std.fmt.bufPrint(&pathbuf, config.pane_addr ++ "{d}", .{cand.ref}) catch unreachable), // short + .panes => meta.path = @constCast(std.fmt.bufPrint(&pathbuf, config.pane_addr ++ "{d}", .{cand.ref}) catch unreachable), // @p and a u32 fit 4128 .symbols => { const owner = p.panes[p.paneBySerial(q.owner) orelse 0]; meta.path = @constCast(if (owner) |o| addressOf(p.scratch.allocator(), o) else ""); diff --git a/src/builtins.zig b/src/builtins.zig index 76fb959d..c500ee56 100644 --- a/src/builtins.zig +++ b/src/builtins.zig @@ -597,11 +597,11 @@ pub fn warnModifiedIn(c: Ctx, asking: Pane.Discarding, which: Asked) bool { c.p.reportFailure(c.id, std.fmt.bufPrint(&short, "{d} unsaved pane{s} \u{2014} {s} again to discard", .{ count, if (count == 1) "" else "s", @tagName(asking) }) catch unreachable); // a u32 and 48 fit 96 } if (count > 0 and (c.p.fs.no_prompt or c.p.fs.capturing)) { - var said_buf: [limits.host_path_cap + 96]u8 = undefined; - const said = (if (count == 1) - std.fmt.bufPrint(&said_buf, "{s}: Modified ({s} again to discard)", .{ one, @tagName(asking) }) + var said_buf: pardes.Kind.Buf(limits.host_path_cap + 96) = .{}; + const said = if (count == 1) + said_buf.print("{s}: Modified ({s} again to discard)", .{ one, @tagName(asking) }) else - std.fmt.bufPrint(&said_buf, "{d} unsaved panes: Modified ({s} again to discard)", .{ count, @tagName(asking) })) catch unreachable; // one is one_buf's at most + said_buf.print("{d} unsaved panes: Modified ({s} again to discard)", .{ count, @tagName(asking) }); var room: @TypeOf(c.p.fs.failure) = undefined; const kept = pardes.ctlfs.fitErr(said, &room); @memcpy(c.p.fs.failure[0..kept.len], kept); @@ -715,7 +715,7 @@ pub const Restore = struct { // First, so a Restore that could never happen spends no warning. if (file) |path| { const bytes = @import("fs.zig").readFile(c.p.gpa, path) catch |err| { - var buf: [limits.host_path_cap + 160]u8 = undefined; + var buf: pardes.Kind.Buf(limits.host_path_cap + 160) = .{}; var words: [128]u8 = undefined; const why = switch (err) { error.FileNotFound => "no such file", @@ -723,15 +723,15 @@ pub const Restore = struct { error.IsDirectory => "a directory, not a dump", else => pardes.Messages.errorWords(err, &words), }; - return c.p.reportFailure(c.id, std.fmt.bufPrint(&buf, "Restore: {s}: {s}", .{ path[0..@min(path.len, limits.host_path_cap)], why }) catch unreachable); // cap and 128 fit + return c.p.reportFailure(c.id, buf.print("Restore: {s}: {s}", .{ path[0..@min(path.len, limits.host_path_cap)], why })); }; defer c.p.gpa.free(bytes); // Nor does a file that is not a dump, before any warning. var why_buf: [256]u8 = undefined; pardes.dump.check(c.p.gpa, bytes, &why_buf) catch |err| { - var buf: [limits.host_path_cap + 320]u8 = undefined; + var buf: pardes.Kind.Buf(limits.host_path_cap + 320) = .{}; const why = if (err == error.OutOfMemory) pardes.Messages.errorWords(err, &why_buf) else why_buf[0..std.mem.indexOfScalar(u8, &why_buf, 0).?]; - return c.p.reportFailure(c.id, std.fmt.bufPrint(&buf, "Restore: {s}: not a pardes dump: {s}", .{ path[0..@min(path.len, limits.host_path_cap)], why }) catch unreachable); // cap and 256 fit + return c.p.reportFailure(c.id, buf.print("Restore: {s}: not a pardes dump: {s}", .{ path[0..@min(path.len, limits.host_path_cap)], why })); }; } // acme's Load adds a dump's windows to the ones there; a Restore @@ -1069,10 +1069,10 @@ pub const Get = struct { if (ctl.getRefused(c.p, c.pane, "Get")) |said| return c.p.reportFailure(c.id, said); const errno = if (typed.len == 0) ctl.get(c.p, c.pane, &failed) else ctl.getFile(c.p, c.pane, path, &failed); if (errno != 0) { - var said: [400]u8 = undefined; + var said: pardes.Kind.Buf(400) = .{}; var words: [128]u8 = undefined; const why = if (failed == error.FileNotFound) "no such file" else pardes.Messages.errorWords(failed, &words); - c.p.reportFailure(c.id, std.fmt.bufPrint(&said, "Get: {s}: {s}", .{ path[0..@min(path.len, 256)], why }) catch unreachable); // 256 and 128 fit 400 + c.p.reportFailure(c.id, said.print("Get: {s}: {s}", .{ path[0..@min(path.len, 256)], why })); } } }; @@ -1114,18 +1114,18 @@ pub const Incl = struct { // is absolute (or ~) and there. var check = std.mem.tokenizeAny(u8, typed, " \t"); while (check.next()) |dir_word| { - var said: [320]u8 = undefined; + var said: pardes.Kind.Buf(320) = .{}; const shown = dir_word[0..@min(dir_word.len, 200)]; if (std.mem.eql(u8, dir_word, "-")) return p.reportFailure(c.id, "Incl: invalid: - clears the list, alone"); if (dir_word[0] != '/' and dir_word[0] != '~') - return p.reportFailure(c.id, std.fmt.bufPrint(&said, "Incl: invalid directory: {s} is relative", .{shown}) catch unreachable); // 200 fit 320 + return p.reportFailure(c.id, said.print("Incl: invalid directory: {s} is relative", .{shown})); var home_buf: [4096]u8 = undefined; const expanded = @import("fs.zig").expandHome(dir_word, &home_buf); if (@import("fs.zig").localPath(expanded)) |local| if (exec.kindOf(local) != .directory) return p.reportFailure(c.id, if (exec.kindOf(local) != null) - std.fmt.bufPrint(&said, "Incl: not a directory: {s}", .{shown}) catch unreachable // 200 fit 320 + said.print("Incl: not a directory: {s}", .{shown}) else - std.fmt.bufPrint(&said, "Incl: no such directory: {s}", .{shown}) catch unreachable); // 200 fit 320 + said.print("Incl: no such directory: {s}", .{shown})); } var words = std.mem.tokenizeAny(u8, typed, " \t"); while (words.next()) |dir_word| { @@ -1210,7 +1210,7 @@ pub const Save = struct { if (c.pane.file == null and !c.pane.isTerminal()) { const kind = if (c.pane.addon) |k| k.nameOf() else ""; var said: [64]u8 = undefined; - return c.p.reportFailure(c.id, std.fmt.bufPrint(&said, "Save: a{s} {s} pane has no text to save", .{ if (kind.len > 0 and std.mem.indexOfScalar(u8, "aeiou", kind[0]) != null) "n" else "", kind }) catch unreachable); // a kind's 16-byte name and 35 fit 64 + return c.p.reportFailure(c.id, std.fmt.bufPrint(&said, "Save: a{s} {s} pane has no text to save", .{ if (kind.len > 0 and std.mem.indexOfScalar(u8, "aeiou", kind[0]) != null) "n" else "", kind[0..@min(kind.len, 16)] }) catch unreachable); // 16 and 36 fit 64 } // A directory's listing is no file to write, bare or to a path, as // acme's Put does nothing in a directory window. @@ -1421,8 +1421,8 @@ pub const Term = struct { var why: [320]u8 = undefined; // The authority's lookup, taped, as Shell's (exec.zig). if (pardes.tape.value(.shell, @import("host_io.zig").Shell.refusal, .{ arg[0..@min(arg.len, 200)], &why })) |refused| { - var said: [340]u8 = undefined; - return c.p.reportFailure(c.id, std.fmt.bufPrint(&said, "Term: {s}", .{refused}) catch unreachable); // refused is at most why's 320 + var said: pardes.Kind.Buf(340) = .{}; + return c.p.reportFailure(c.id, said.print("Term: {s}", .{refused})); } } const pane = exec.spawnTty(c.p, c.id) orelse return; @@ -1451,11 +1451,11 @@ pub const Repl = struct { if (!pane.isTerminal() or pane.terminal == null) return c.p.reportFailure(c.id, "Repl: only a terminal is a REPL"); if (pane.command != null and pane.command_done) return c.p.reportFailure(c.id, "Repl: its command is done; a REPL is a running program"); const arg = std.mem.trim(u8, c.arg orelse "", " \t\r\n"); - var buf: [320]u8 = undefined; + var buf: pardes.Kind.Buf(320) = .{}; var idbuf: [48]u8 = undefined; if (arg.len == 0) { if (pane.repl == null) return c.p.setMessage(c.id, "Repl: not bound"); - return c.p.setMessage(c.id, std.fmt.bufPrint(&buf, "Repl: {s}", .{exec.replId(&idbuf, pane)}) catch unreachable); // 48 fit 320 + return c.p.setMessage(c.id, buf.print("Repl: {s}", .{exec.replId(&idbuf, pane)})); } if (std.mem.eql(u8, arg, "-")) { pane.repl = null; @@ -1467,27 +1467,30 @@ pub const Repl = struct { const named: ?u8 = if (manifest.byName(arg)) |i| if (grammars[i].exts.len > 0) @intCast(i) else null else null; const lang: u8 = named orelse { // A few, whole, and where the rest are: a list cut to fit the - // row would end mid-word. unreachable: 24, six names and 60 fit 320. - var w = std.Io.Writer.fixed(&buf); - w.print("Repl: invalid language \"{s}\"; - or one like", .{@import("Messages.zig").clip(arg, 24)}) catch unreachable; - // Those that start as the word does first, a misspelling's - // likeliest meaning (pithon: python). - var shown: usize = 0; - var known: usize = 0; - for ([2]bool{ true, false }) |alike| for (grammars) |g| if (g.exts.len > 0) { - const starts = arg.len > 0 and g.name[0] == std.ascii.toLower(arg[0]); - if (starts != alike) continue; - known += 1; - if (shown < 6) { - w.print(" {s}", .{g.name}) catch unreachable; - shown += 1; - } - }; - w.print(" ({d} more)", .{known - shown}) catch unreachable; + // row would end mid-word. + var w = std.Io.Writer.fixed(&buf.bytes); + list: { + // A list past the room is cut at its end. + w.print("Repl: invalid language \"{s}\"; - or one like", .{@import("Messages.zig").clip(arg, 24)}) catch break :list; + // Those that start as the word does first, a misspelling's + // likeliest meaning (pithon: python). + var shown: usize = 0; + var known: usize = 0; + for ([2]bool{ true, false }) |alike| for (grammars) |g| if (g.exts.len > 0) { + const starts = arg.len > 0 and g.name[0] == std.ascii.toLower(arg[0]); + if (starts != alike) continue; + known += 1; + if (shown < 6) { + w.print(" {s}", .{g.name}) catch break :list; + shown += 1; + } + }; + w.print(" ({d} more)", .{known - shown}) catch break :list; + } return c.p.reportFailure(c.id, w.buffered()); }; if (pane.repl) |r| if (r.lang == lang) - return c.p.setMessage(c.id, std.fmt.bufPrint(&buf, "Repl: {s}", .{exec.replId(&idbuf, pane)}) catch unreachable); // 48 fit 320 + return c.p.setMessage(c.id, buf.print("Repl: {s}", .{exec.replId(&idbuf, pane)})); // The lowest letter no other REPL of the language has: freed ones // come back. var letter: u8 = 'a'; @@ -1501,7 +1504,7 @@ pub const Repl = struct { if (letter > 'z') return c.p.reportFailure(c.id, "Repl: every letter of the language is taken"); pane.repl = .{ .lang = lang, .letter = letter }; pane.repl_warned = false; - c.p.setMessage(c.id, std.fmt.bufPrint(&buf, "Repl: {s}", .{exec.replId(&idbuf, pane)}) catch unreachable); // 48 fit 320 + c.p.setMessage(c.id, buf.print("Repl: {s}", .{exec.replId(&idbuf, pane)})); } }; diff --git a/src/edit_cmd.zig b/src/edit_cmd.zig index 1a99e76c..0f10e136 100644 --- a/src/edit_cmd.zig +++ b/src/edit_cmd.zig @@ -178,7 +178,7 @@ pub fn run(p: *Pardes, id: usize, command: []const u8) void { var why: sam.Why = .{}; var text: [260]u8 = undefined; const res = sam.run(arena, files.items, cur, command, .{ .ctx = &world, .check = World.check, .open = World.open, .read = World.read, .refuseGet = World.refuseGet }, &why) catch |err| switch (err) { - error.Edit => return p.reportFailure(id, std.fmt.bufPrint(&text, "Edit: {s}", .{why.text()}) catch unreachable), // why's 200 fit 260 + error.Edit => return p.reportFailure(id, std.fmt.bufPrint(&text, "Edit: {s}", .{why.text()}) catch unreachable), // why.text() is a slice of Why's [200]u8 buf; 6 more fit 260 error.OutOfMemory => return p.reportError(id, "Edit", err), }; // acme's Edit blocks the editor while its commands run; here the editor @@ -347,12 +347,10 @@ fn commit(p: *Pardes, pd: *Pending, outputs: []const []const u8) void { var text: [320]u8 = undefined; for (res.files, 0..) |f, i| { if (f.ops.items.len == 0 and !f.close and !f.renamed and !f.moved and f.get == null) continue; - // unreachable: 256 of the name and 56 fit 320. - const name = f.name[0..@min(f.name.len, 256)]; - const pane = p.panes[f.id] orelse return p.reportFailure(at, std.fmt.bufPrint(&text, "Edit: {s} closed while its commands ran; nothing changed", .{name}) catch unreachable); - if (pane.serial != pd.serials[i]) return p.reportFailure(at, std.fmt.bufPrint(&text, "Edit: {s} closed while its commands ran; nothing changed", .{name}) catch unreachable); + const pane = p.panes[f.id] orelse return p.reportFailure(at, std.fmt.bufPrint(&text, "Edit: {s} closed while its commands ran; nothing changed", .{f.name[0..@min(f.name.len, 256)]}) catch unreachable); // 256 and 56 fit 320 + if (pane.serial != pd.serials[i]) return p.reportFailure(at, std.fmt.bufPrint(&text, "Edit: {s} closed while its commands ran; nothing changed", .{f.name[0..@min(f.name.len, 256)]}) catch unreachable); // 256 and 56 fit 320 if ((f.ops.items.len > 0 or f.get != null) and pane.file.?.revision != pd.revisions[i]) - return p.reportFailure(at, std.fmt.bufPrint(&text, "Edit: {s} changed while its commands ran; nothing changed", .{name}) catch unreachable); + return p.reportFailure(at, std.fmt.bufPrint(&text, "Edit: {s} changed while its commands ran; nothing changed", .{f.name[0..@min(f.name.len, 256)]}) catch unreachable); // 256 and 57 fit 320 } // e first, Get's way: read before anything is changed, so one that // cannot be read changes nothing; its own undo step puts the old name diff --git a/src/exec.zig b/src/exec.zig index f90a2315..46bf54c3 100644 --- a/src/exec.zig +++ b/src/exec.zig @@ -475,7 +475,7 @@ pub fn replLive(p: *const Pardes, id: usize) bool { /// `python-a`. pub fn replId(buf: *[48]u8, pane: *const Pane) []const u8 { const r = pane.repl orelse return ""; - return std.fmt.bufPrint(buf, "{s}-{c}", .{ grammars[r.lang].name, r.letter }) catch unreachable; // a grammar's name is short + return std.fmt.bufPrint(buf, "{s}-{c}", .{ grammars[r.lang].name, r.letter }) catch unreachable; // a comptime grammar name and a letter fit 48 } const Routed = union(enum) { none, sent: usize, asked }; @@ -484,8 +484,8 @@ const Routed = union(enum) { none, sent: usize, asked }; /// and nothing sent or run. pub fn replGone(p: *Pardes, from: usize, repl: *const Pane) Routed { var idbuf: [48]u8 = undefined; - var said: [128]u8 = undefined; - p.setMessage(from, std.fmt.bufPrint(&said, "Repl: {s} has no program running; nothing sent", .{replId(&idbuf, repl)}) catch unreachable); // 48 and 44 fit 128 + var said: pardes.Kind.Buf(128) = .{}; + p.setMessage(from, said.print("Repl: {s} has no program running; nothing sent", .{replId(&idbuf, repl)})); return .asked; } @@ -628,11 +628,11 @@ pub fn sendToRepl(p: *Pardes, from: usize, to: usize, text: []const u8) void { std.mem.indexOfScalar(u8, text, '\n') != null) { dst.repl_warned = true; - var warn: [128]u8 = undefined; - p.setMessage(from, std.fmt.bufPrint(&warn, "Repl: {s} takes no bracketed paste; a blank line in a block ends it", .{id}) catch unreachable); // a 48-byte id and 66 fit 128 + var warn: pardes.Kind.Buf(128) = .{}; + p.setMessage(from, warn.print("Repl: {s} takes no bracketed paste; a blank line in a block ends it", .{id})); } - var said: [64]u8 = undefined; - p.setMessage(from, std.fmt.bufPrint(&said, "\u{2192} {s}", .{id}) catch unreachable); // a 48-byte id and 4 fit 64 + var said: pardes.Kind.Buf(64) = .{}; + p.setMessage(from, said.print("\u{2192} {s}", .{id})); src.msg_sent = true; var rec: [96]u8 = undefined; pardes.ctlfs.events.notePath(p, "send", std.fmt.bufPrint(&rec, "{d} {d} {s}", .{ src.serial, dst.serial, id }) catch return); @@ -689,8 +689,8 @@ pub fn executeFrom(p: *Pardes, id: usize, txt: []const u8, from_body: bool) ?usi // never run as a shell command. const word = cmd[0 .. std.mem.indexOfAny(u8, cmd, " \t") orelse cmd.len]; if (builtins.absentWhy(word) orelse if (config.Runtime.find(word) != null) @as([]const u8, "GUI-only") else null) |why| { - var said: [96]u8 = undefined; - p.reportFailure(id, std.fmt.bufPrint(&said, "{s} is {s}, invalid here", .{ word, why }) catch unreachable); // a known word (15 at most) and 17 fit 96 + var said: pardes.Kind.Buf(96) = .{}; + p.reportFailure(id, said.print("{s} is {s}, invalid here", .{ word, why })); return null; } // A command from a column's or the workspace's tag is that tag's: a @@ -806,12 +806,14 @@ fn winid(p: *const Pardes, src: ?*Pane) u32 { /// what it was given; its newlines the terminal's, so a multi-line command /// does not staircase. fn echoCommand(p: *Pardes, pane: *Pane, line: []const u8) void { - // unreachable: runCommand takes no line over command_max, each byte two at most. var buf: [2 * command_max + 8]u8 = undefined; var w = std.Io.Writer.fixed(&buf); - w.writeAll(if (panes.terminal.gridCursor(pane).x != 0) "\r\n% " else "% ") catch unreachable; - for (line) |c| (if (c == '\n') w.writeAll("\r\n") else w.writeByte(c)) catch unreachable; - w.writeAll("\r\n") catch unreachable; + // A line past the room is cut at its end. + echo: { + w.writeAll(if (panes.terminal.gridCursor(pane).x != 0) "\r\n% " else "% ") catch break :echo; + for (line) |c| (if (c == '\n') w.writeAll("\r\n") else w.writeByte(c)) catch break :echo; + w.writeAll("\r\n") catch break :echo; + } panes.terminal.feedOutput(p, pane, w.buffered()); } @@ -821,8 +823,8 @@ fn echoCommand(p: *Pardes, pane: *Pane, line: []const u8) void { /// announced first, so `new` comes before the `run` in it. pub fn noteRun(p: *Pardes, pane: *Pane, what: []const u8, said: []const u8) void { pardes.ctlfs.events.announce(p); - var buf: [command_max + 16]u8 = undefined; - pardes.ctlfs.events.notePath(p, what, std.fmt.bufPrint(&buf, "{d} {s}", .{ pane.serial, std.mem.trim(u8, said, " \t\r\n") }) catch unreachable); // a run's line is at most command_max + var buf: pardes.Kind.Buf(command_max + 16) = .{}; + pardes.ctlfs.events.notePath(p, what, buf.print("{d} {s}", .{ pane.serial, std.mem.trim(u8, said, " \t\r\n") })); } /// A command pane's child is gone: the pane stays, showing what it said @@ -841,10 +843,10 @@ pub fn commandDone(p: *Pardes, id: usize, status: ?u8) void { if (status == 0) return p.removePane(id, null) catch {}; } var buf: [16]u8 = undefined; - const code = if (status) |n| std.fmt.bufPrint(&buf, "{d}", .{n}) catch unreachable else "?"; // a status fits 16 + const code = if (status) |n| std.fmt.bufPrint(&buf, "{d}", .{n}) catch unreachable else "?"; // an exit status fits 16 var said: [32]u8 = undefined; const lead = if (panes.terminal.gridCursor(pane).x != 0) "\r\n" else ""; - panes.terminal.feedOutput(p, pane, std.fmt.bufPrint(&said, "{s}exit {s}\r\n", .{ lead, code }) catch unreachable); // 16 and 9 fit 32 + panes.terminal.feedOutput(p, pane, std.fmt.bufPrint(&said, "{s}exit {s}\r\n", .{ lead, code }) catch unreachable); // a literal, the [16]u8 code and 7 fit 32 noteRun(p, pane, "exit", code); p.needs_frame = true; } @@ -966,8 +968,8 @@ fn applyInitText(p: *Pardes, text: []const u8, settings_only: bool) void { const why: []const u8 = if (!known) std.fmt.bufPrint(&why_buf, "unknown word \"{s}\"", .{word[0..@min(word.len, 64)]}) catch unreachable // 64 fit 320 else if (p.fs.said_len > 0) p.fs.said[0..p.fs.said_len] else "failed"; - var said: [400]u8 = undefined; - const line_said = std.fmt.bufPrint(&said, "init file line {d}: {s}", .{ number, why }) catch unreachable; // why is 320 at most + var said: pardes.Kind.Buf(400) = .{}; + const line_said = said.print("init file line {d}: {s}", .{ number, why }); if (!known) p.reportFailure(p.view().active, line_said); pardes.ctlfs.events.notePath(p, "err -", line_said); } @@ -1003,7 +1005,7 @@ pub fn runBuiltinFrom(p: *Pardes, b: Builtin, id: usize, txt: []const u8, arg: ? // silent nothing (Palette on a file, Filter on a PDF). if (builtins.registry.needs(b)) |kind| if (p.panes[id] == null or !kind.has(pane)) { var said: [96]u8 = undefined; - return p.reportFailure(id, std.fmt.bufPrint(&said, "{s}: only {s} pane takes it", .{ @tagName(b), kind.noun() }) catch unreachable); // short names + return p.reportFailure(id, std.fmt.bufPrint(&said, "{s}: only {s} pane takes it", .{ @tagName(b), kind.noun() }) catch unreachable); // an enum's name and a literal noun fit 96 }; const c: builtins.Ctx = .{ .p = p, .pane = pane, .id = id, .txt = txt, .arg = arg, .from_body = from_body }; builtins.registry.dispatch(b, c); @@ -1023,8 +1025,8 @@ pub fn applySettingBuiltin(p: *Pardes, setting: config.Runtime.Setting, arg: ?[] const shown = want[0..@min(want.len, 40)]; const room = 128 -| ("Theme: no theme \"\"; like it: ; Themes lists all".len + shown.len); var near: [128]u8 = undefined; - var text: [256]u8 = undefined; - return p.reportFailure(v.active, std.fmt.bufPrint(&text, "Theme: no theme \"{s}\"; like it: {s}; Themes lists all", .{ shown, colors.themesNear(near[0..@min(room, near.len)], want) }) catch unreachable); // 40 and 128 of names fit 256 + var text: pardes.Kind.Buf(256) = .{}; + return p.reportFailure(v.active, text.print("Theme: no theme \"{s}\"; like it: {s}; Themes lists all", .{ shown, colors.themesNear(near[0..@min(room, near.len)], want) })); }, .font => { if (comptime !font_picker) return; @@ -1047,8 +1049,8 @@ pub fn applySettingBuiltin(p: *Pardes, setting: config.Runtime.Setting, arg: ?[] } var why: [320]u8 = undefined; if (pardes.tape.value(.shell, @import("host_io.zig").Shell.refusal, .{ want[0..@min(want.len, 200)], &why })) |refused| { - var text: [340]u8 = undefined; - return p.reportFailure(v.active, std.fmt.bufPrint(&text, "Shell: {s}", .{refused}) catch unreachable); // refused is at most why's 320 + var text: pardes.Kind.Buf(340) = .{}; + return p.reportFailure(v.active, text.print("Shell: {s}", .{refused})); } if (!p.settings.apply(setting, want)) p.reportFailure(v.active, "Shell: takes " ++ comptime config.Runtime.takes(.shell).?); }, @@ -1058,7 +1060,7 @@ pub fn applySettingBuiltin(p: *Pardes, setting: config.Runtime.Setting, arg: ?[] return p.setMessage(v.active, std.fmt.bufPrint(&said, "{s} {d}", .{ setting.word, @field(p.settings, @tagName(tag)) }) catch unreachable); // a setting's word is 14 at most } else if (!p.settings.apply(setting, arg)) { var said: [96]u8 = undefined; - p.reportFailure(v.active, std.fmt.bufPrint(&said, "{s}{s}: takes {s}", .{ setting.word, if (tag == .tab) ": invalid tab width" else "", comptime config.Runtime.takes(tag).? }) catch unreachable); // short literals + p.reportFailure(v.active, std.fmt.bufPrint(&said, "{s}{s}: takes {s}", .{ setting.word, if (tag == .tab) ": invalid tab width" else "", comptime config.Runtime.takes(tag).? }) catch unreachable); // a comptime word and two literals fit 96 } else if (tag == .tab) { config.tab_now = p.settings.tab; }, diff --git a/src/lsp/Ask.zig b/src/lsp/Ask.zig index 76c32f2d..6b5dd8c8 100644 --- a/src/lsp/Ask.zig +++ b/src/lsp/Ask.zig @@ -60,7 +60,7 @@ pub fn lspRequest(p: *Pardes, asked: usize, kind: lsp.Kind, arg_in: []const u8) const zig_buf = if (pane.file) |f| std.mem.endsWith(u8, f.path, ".zig") else true; if ((zig_buf and (!std.zig.isValidId(arg) or std.zig.isUnderscore(arg))) or (!zig_buf and std.mem.indexOfAny(u8, arg, " \t\r\n\"\\") != null)) - return p.reportFailure(id, std.fmt.bufPrint(&said, "Rename: {s} is no name", .{arg}) catch unreachable); // arg is 128 at most + return p.reportFailure(id, std.fmt.bufPrint(&said, "Rename: {s} is no name", .{arg[0..@min(arg.len, 128)]}) catch unreachable); // 128 and 19 fit 160 } var off = if (pane.file) |f| modal.offsetAt(f.content, .{ .row = @intCast(@max(0, pane.body.cur_row)), @@ -83,7 +83,7 @@ pub fn lspRequest(p: *Pardes, asked: usize, kind: lsp.Kind, arg_in: []const u8) } } off = nearest orelse - return p.reportFailure(id, std.fmt.bufPrint(&said, "{s}: no {s} in this file", .{ lspWord(kind), arg }) catch unreachable); // a word, 128 and 18 fit 160 + return p.reportFailure(id, std.fmt.bufPrint(&said, "{s}: no {s} in this file", .{ lspWord(kind), arg[0..@min(arg.len, 128)] }) catch unreachable); // a literal word, 128 and 18 fit 160 arg = ""; } // Lspwhy asks the last query again, narrated: its kind and argument, @@ -93,7 +93,7 @@ pub fn lspRequest(p: *Pardes, asked: usize, kind: lsp.Kind, arg_in: []const u8) var at = off; if (kind == .explain) { if (p.lsp_ask.last) |last| { - sent = std.fmt.bufPrint(&explained, "{s} {s}", .{ @tagName(last.kind), last.arg.slice() }) catch unreachable; // a kind's name and 128 fit 160 + sent = std.fmt.bufPrint(&explained, "{s} {s}", .{ @tagName(last.kind), last.arg.slice() }) catch unreachable; // an enum's name and a Buf(128) fit 160 if (last_pane != null) at = last.offset; } } else if (kind != .status) p.lsp_ask.last = .{ .kind = kind, .arg = .from(arg), .serial = pane.serial, .offset = @intCast(off) }; @@ -275,7 +275,7 @@ pub fn lspResponse(p: *Pardes, id: u32, response: ?[]const u8) void { defer if (p.fs.failures != failures) p.noteLateFailure(w.pane); var said: [256]u8 = undefined; const rows = response orelse - return p.reportFailure(w.pane, std.fmt.bufPrint(&said, "{s}: the language server did not answer", .{lspWord(w.kind)}) catch unreachable); // short + return p.reportFailure(w.pane, std.fmt.bufPrint(&said, "{s}: the language server did not answer", .{lspWord(w.kind)}) catch unreachable); // a literal word and 40 fit 256 // A backend that cannot answer it says why (`@none <why>`). if (std.mem.startsWith(u8, rows, "@none ")) { const why = std.mem.trimEnd(u8, rows["@none ".len..], "\n"); @@ -293,7 +293,7 @@ pub fn lspResponse(p: *Pardes, id: u32, response: ?[]const u8) void { if (applyLspEdits(p, pane, w.revision, edits)) { var buf: [64]u8 = undefined; const verb: []const u8 = if (w.kind == .rename) "renamed" else "formatted"; - p.setMessage(w.pane, std.fmt.bufPrint(&buf, "{s} {d} range(s)", .{ verb, edits.len }) catch unreachable); // short + p.setMessage(w.pane, std.fmt.bufPrint(&buf, "{s} {d} range(s)", .{ verb, edits.len }) catch unreachable); // a literal and a usize fit 64 } return; } @@ -311,13 +311,13 @@ pub fn lspResponse(p: *Pardes, id: u32, response: ?[]const u8) void { const none: ?[]const u8 = switch (w.kind) { .completion, .format => null, .rename => "nothing here to rename", - .diagnostics, .workspace_diagnostics => return p.setMessage(w.pane, std.fmt.bufPrint(&said, "{s}: none", .{lspWord(w.kind)}) catch unreachable), // short + .diagnostics, .workspace_diagnostics => return p.setMessage(w.pane, std.fmt.bufPrint(&said, "{s}: none", .{lspWord(w.kind)}) catch unreachable), // a literal word fits 256 .incoming_calls => "callers not found", .outgoing_calls => "callees not found", .hover => "nothing to show: not found", else => "not found", }; - if (none) |text| p.reportFailure(w.pane, std.fmt.bufPrint(&said, "{s}: {s}", .{ lspWord(w.kind), text }) catch unreachable); // short literals + if (none) |text| p.reportFailure(w.pane, std.fmt.bufPrint(&said, "{s}: {s}", .{ lspWord(w.kind), text }) catch unreachable); // two literals fit 256 return; } @@ -399,9 +399,9 @@ pub fn lspResponse(p: *Pardes, id: u32, response: ?[]const u8) void { // renameEdits) are no edits. const unrenamed = std.mem.count(u8, rows, ", which the server did not rename\n"); p.setMessage(w.pane, if (unrenamed > 0) - std.fmt.bufPrint(&said_buf, "Rename: previewed, not applied: the server renamed in this file only, and {d} other open file(s) say the name", .{unrenamed}) catch unreachable // 126 at most + std.fmt.bufPrint(&said_buf, "Rename: previewed, not applied: the server renamed in this file only, and {d} other open file(s) say the name", .{unrenamed}) catch unreachable // a usize and 106 fit 128 else - std.fmt.bufPrint(&said_buf, "Rename: {d} edit(s) across files, previewed, not applied", .{nrows}) catch unreachable); // short + std.fmt.bufPrint(&said_buf, "Rename: {d} edit(s) across files, previewed, not applied", .{nrows}) catch unreachable); // a usize and 50 fit 128 } if (panes.Output.traits(from).jumps) { const result = p.panes[pane.search_pane orelse return] orelse return; diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index 08bad9c3..d21e58a3 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -320,7 +320,7 @@ pub fn captured(p: *Pardes, req: Req, id: usize, exec: bool, text: []const u8, i pub fn failedWrite(p: *Pardes, tag: u64) ?Reply { if (p.fs.failure_len == 0) return null; const failure = p.fs.failure[0..p.fs.failure_len]; - return tree.failText(tag, failureErrno(failure), std.fmt.bufPrint(&p.fs.ename, "{s}", .{failure}) catch unreachable); // failure's 256 bytes fit ename's 320 + return tree.failText(tag, failureErrno(failure), std.fmt.bufPrint(&p.fs.ename, "{s}", .{failure}) catch unreachable); // failure is a slice of fs.failure, a [256]u8, into ename's 320 } /// The errno a builtin's failure answers with: ENOENT for what is not @@ -419,7 +419,6 @@ pub const pane_text_cap = 9 * 12 + 2 * 256 + 4 + "notcurrent ".len + 48 + "colla /// window has the keyboard, `current` or `notcurrent` (rio(4), wctl), and /// a REPL's id. pub fn paneText(p: *Pardes, pane: *Pane, buf: *[pane_text_cap]u8) []const u8 { - // unreachable below: pane_text_cap counts every field at its widest. var w = std.Io.Writer.fixed(buf); w.print("{d:>11} {d:>11} {d:>11} {d:>11} {d:>11} {d:>11} ", .{ pane.serial, @@ -430,30 +429,30 @@ pub fn paneText(p: *Pardes, pane: *Pane, buf: *[pane_text_cap]u8) []const u8 { @intFromBool(if (pane.file) |f| f.listing != null else false), @intFromBool(pane_files.dirtyOf(pane)), pane.cols, - }) catch unreachable; + }) catch unreachable; // integers: pane_text_cap counts them at 11 each const font = p.settings.font.effective_name.get(); - writeQuoted(&w, if (font.len == 0) "default" else font) catch unreachable; + writeQuoted(&w, if (font.len == 0) "default" else font) catch unreachable; // a Text(255) quoted is 2 * 256 at most, counted // While a column's or the workspace's tag has the keyboard, no pane does. const current = p.panes[p.view().active] == pane and p.view().header == null; const f = pane_files.fileOf(pane); const undo = if (f) |file| file.history.journal.done > 0 else false; const redo = if (f) |file| file.history.journal.done < file.history.journal.steps.items.len else false; - w.print(" {d:>11} {d:>11} {d:>11} {s} ", .{ config.tab_now, @intFromBool(undo), @intFromBool(redo), if (current) "current" else "notcurrent" }) catch unreachable; + w.print(" {d:>11} {d:>11} {d:>11} {s} ", .{ config.tab_now, @intFromBool(undo), @intFromBool(redo), if (current) "current" else "notcurrent" }) catch unreachable; // integers and a literal, counted // A terminal bound as a REPL ends with its id, `python-a`. var idbuf: [48]u8 = undefined; const id = exec_line.replId(&idbuf, pane); - if (id.len > 0) w.print("{s} ", .{id}) catch unreachable; + if (id.len > 0) w.print("{s} ", .{id[0..@min(id.len, idbuf.len)]}) catch unreachable; // 48, counted // Then what its tag does not say: Collapse, and a kind's own fields (a // PDF's PdfFit and PdfTint, in the words they take). - if (pane.collapsed) w.writeAll("collapsed ") catch unreachable; + if (pane.collapsed) w.writeAll("collapsed ") catch unreachable; // a literal, counted if (pane.addon != null) { var fields: [128]u8 = undefined; const kind_fields = pardes.Kind.ctlRead(pane, &fields); - if (kind_fields.len > 0) w.print("{s} ", .{kind_fields}) catch unreachable; + if (kind_fields.len > 0) w.print("{s} ", .{kind_fields[0..@min(kind_fields.len, fields.len)]}) catch unreachable; // 128 and a blank, counted } // Last, the body's mode, which the tag shows as a box: helix's select // is normal mode extending. - w.print("mode:{s} ", .{if (pane.body.mode == .normal and pane.body.select) "select" else @tagName(pane.body.mode)}) catch unreachable; + w.print("mode:{s} ", .{if (pane.body.mode == .normal and pane.body.select) "select" else @tagName(pane.body.mode)}) catch unreachable; // an enum's name, counted return w.buffered(); } @@ -534,10 +533,10 @@ fn checkBuiltin(p: *Pardes, req: Req, line: []const u8, scope: builtins.Scope) ? // terminal, the window's own words in a terminal's view) is known, // and says so rather than sound misspelt. if (builtins.absentWhy(word) orelse if (config.Runtime.find(word) != null or std.meta.stringToEnum(Builtin, word) != null) @as([]const u8, "GUI-only") else null) |absent| { - var why: [64]u8 = undefined; + var why: pardes.Kind.Buf(64) = .{}; // EINVAL, a request this build cannot take, in words 9ns reads // as that: `invalid`. - return refuse(p, req, std.fmt.bufPrint(&why, "{s} is {s}, invalid here", .{ word, absent }) catch unreachable, line); // a known word (15 at most) and 17 fit 64 + return refuse(p, req, why.print("{s} is {s}, invalid here", .{ word, absent }), line); } return refuse(p, req, "unknown control message", line); }; @@ -560,8 +559,8 @@ fn checkBuiltin(p: *Pardes, req: Req, line: []const u8, scope: builtins.Scope) ? const tail = "; Themes lists all"; var near: [128]u8 = undefined; const room = @import("cloud9").fs.errmax -| (head.len + tail.len + line.len + 3); - var why: [256]u8 = undefined; - return refuse(p, req, std.fmt.bufPrint(&why, head ++ "{s}" ++ tail, .{pardes.colors.themesNear(near[0..@min(room, near.len)], arg)}) catch unreachable, arg); // 128 of names fit + var why: pardes.Kind.Buf(256) = .{}; + return refuse(p, req, why.print(head ++ "{s}" ++ tail, .{pardes.colors.themesNear(near[0..@min(room, near.len)], arg)}), arg); }, .font => config.Runtime.FontSpec.parse(arg) != null, // Bare, it says the width, as from a pane's exec. @@ -1107,9 +1106,9 @@ pub fn writePane(p: *Pardes, req: Req, pane: *Pane) Reply { const path = if (pane_files.fileOf(pane)) |f| f.path else ""; var why_buf: [48]u8 = undefined; const why = if (pardes.Messages.dialReason(failed)) |r| - std.fmt.bufPrint(&why_buf, "dial failed: {s}", .{r}) catch unreachable // dialReason's words are short + std.fmt.bufPrint(&why_buf, "dial failed: {s}", .{r}) catch unreachable // dialReason's literals and 13 fit 48 else if (errno == E.NOENT) "no such file" else "cannot be read"; - return tree.failText(req.tag, errno, std.fmt.bufPrint(&p.fs.ename, "get: {s}: {s}", .{ path[0..@min(path.len, 256)], why }) catch unreachable); // 256 and 48 fit 320 + return tree.failText(req.tag, errno, std.fmt.bufPrint(&p.fs.ename, "get: {s}: {s}", .{ path[0..@min(path.len, 256)], why[0..@min(why.len, 48)] }) catch unreachable); // 256, 48 and 7 fit 320 } }, .lock => { @@ -1127,7 +1126,7 @@ pub fn writePane(p: *Pardes, req: Req, pane: *Pane) Reply { // With a question up, what it offers. var offered: [64]u8 = undefined; if (keys.questionChoices(p, p.paneBySerial(serial).?, &offered)) |choices| - return tree.failText(req.tag, E.INVAL, std.fmt.bufPrint(&p.fs.ename, "answer takes {s} or -", .{choices}) catch unreachable); // 64 fit 320 + return tree.failText(req.tag, E.INVAL, std.fmt.bufPrint(&p.fs.ename, "answer takes {s} or -", .{choices[0..@min(choices.len, 64)]}) catch unreachable); // 64 and 18 fit 320 return tree.failText(req.tag, E.INVAL, "answer takes a choice or -"); }, } else if (std.mem.startsWith(u8, line, "answer ") and p.panes[p.paneBySerial(serial).?].?.prompt == .save) { @@ -1149,9 +1148,9 @@ pub fn writePane(p: *Pardes, req: Req, pane: *Pane) Reply { // Only a choice the question offers answers it; anything // else leaves it standing, and says what it takes. if (!std.mem.eql(u8, choice, "-") and (choice.len != 1 or std.mem.indexOfScalar(u8, choices, choice[0]) == null)) { - var why: [96]u8 = undefined; + var why: pardes.Kind.Buf(96) = .{}; // The choice refused is what is quoted: `answer takes a b or - "z"`. - return refuseQuoting(p, req, std.fmt.bufPrint(&why, "answer takes {s} or -", .{choices}) catch unreachable, choice, ""); // 64 fit 96 + return refuseQuoting(p, req, why.print("answer takes {s} or -", .{choices}), choice, ""); } if (apply) _ = keys.answerQuestion(p, id, if (choice[0] == '-') null else choice[0]); } else if (!apply) { @@ -1223,7 +1222,7 @@ fn acmeCtl(p: *Pardes, req: Req, serial: u32, line: []const u8, apply: bool) Acm .menu, .nomenu => "pardes has no menu", else => "a pane is dumped with the session: Dump and DumpDir on /ctl", }; - return .{ .refused = tree.failText(req.tag, E.INVAL, std.fmt.bufPrint(&p.fs.ename, "invalid: acme's {s}: {s}", .{ word, why }) catch unreachable) }; // short literals + return .{ .refused = tree.failText(req.tag, E.INVAL, std.fmt.bufPrint(&p.fs.ename, "invalid: acme's {s}: {s}", .{ @tagName(w), why }) catch unreachable) }; // an enum's name and a literal fit 320 }, }; if (!apply) return .done; @@ -1257,11 +1256,11 @@ pub fn getRefused(p: *Pardes, pane: *Pane, word: []const u8) ?[]const u8 { tree.events.noteLog(p, .unsaved, pane); const listed = std.fmt.allocPrint(p.gpa, "{s}: Modified\n\n{s} again to discard\n", .{ f.path, word }) catch null; if (listed) |content| panes.Output.openUnsaved(p, id, content); - var notice: [64]u8 = undefined; + var notice: pardes.Kind.Buf(64) = .{}; p.fs.unlogged = true; - p.setMessage(id, std.fmt.bufPrint(¬ice, "1 unsaved pane \u{2014} {s} again to discard", .{word}) catch unreachable); // word is get, Get or e + p.setMessage(id, notice.print("1 unsaved pane \u{2014} {s} again to discard", .{word})); p.fs.unlogged = false; - return std.fmt.bufPrint(&p.fs.ename, "{s}: Modified ({s} again to discard)", .{ f.path[0..@min(f.path.len, 256)], word }) catch unreachable; // 256 fit 320 + return std.fmt.bufPrint(&p.fs.ename, "{s}: Modified ({s} again to discard)", .{ f.path[0..@min(f.path.len, 256)], word[0..@min(word.len, 16)] }) catch unreachable; // 256, 16 and 33 fit 320 } /// acme's `Get file`, and Edit's `e file`: the file at `path` (absolute) diff --git a/src/ninep/events.zig b/src/ninep/events.zig index a25b97b2..be0c4141 100644 --- a/src/ninep/events.zig +++ b/src/ninep/events.zig @@ -174,7 +174,7 @@ pub fn noteLogAs(p: *Pardes, kind: LogKind, pane: *Pane, path: []const u8) void var name_buf: [4 * 4096]u8 = undefined; // As /index shows it: a newline in the name is `\n`. const name = shown(path, &name_buf); - pushLog(p, std.fmt.bufPrint(&buf, "{s} {d} {s}\n", .{ @tagName(kind), pane.serial, name }) catch unreachable); // name is at most name_buf's + pushLog(p, std.fmt.bufPrint(&buf, "{s} {d} {s}\n", .{ @tagName(kind), pane.serial, name[0..@min(name.len, name_buf.len)] }) catch unreachable); // an enum's name, a u32 and name_buf's 4 * 4096 fit 64 more } /// Records `msg <serial> <text>` for what the editor said, `-` for no pane. @@ -189,9 +189,9 @@ pub fn noteMessage(p: *Pardes, serial: u32, said_stamped: []const u8) void { const cut = if (kept.len < said.len) "…" else ""; bootFirst(p); pushCounting(p, (if (serial == 0) - std.fmt.bufPrint(&buf, "msg - {s}{s}\n", .{ kept, cut }) + std.fmt.bufPrint(&buf, "msg - {s}{s}\n", .{ kept[0..@min(kept.len, pardes.Messages.LoggedMessage.cap)], cut }) else - std.fmt.bufPrint(&buf, "msg {d} {s}{s}\n", .{ serial, kept, cut })) catch unreachable, said); // kept is at most cap + std.fmt.bufPrint(&buf, "msg {d} {s}{s}\n", .{ serial, kept[0..@min(kept.len, pardes.Messages.LoggedMessage.cap)], cut })) catch unreachable, said); // a u32, cap and 9 fit cap + 32 } /// `notePath` for an `err` record: the same one again straight after is @@ -199,7 +199,7 @@ pub fn noteMessage(p: *Pardes, serial: u32, said_stamped: []const u8) void { pub fn noteErrCounted(p: *Pardes, text: []const u8) void { bootFirst(p); var buf: [pardes.memory.limits.host_path_cap + 16]u8 = undefined; - pushCounting(p, std.fmt.bufPrint(&buf, "err {s}\n", .{text[0..@min(text.len, buf.len - 16)]}) catch unreachable, text); + pushCounting(p, std.fmt.bufPrint(&buf, "err {s}\n", .{text[0..@min(text.len, buf.len - 16)]}) catch unreachable, text); // buf.len - 16 and 5 fit buf.len } /// Records `<what> <path>`: `dump <path>` when a Dump is written, @@ -207,8 +207,7 @@ pub fn noteErrCounted(p: *Pardes, text: []const u8) void { pub fn notePath(p: *Pardes, what: []const u8, path: []const u8) void { bootFirst(p); var buf: [pardes.memory.limits.host_path_cap + 16]u8 = undefined; - // unreachable: a record's word is a short literal, and the path is cut to fit. - pushLog(p, std.fmt.bufPrint(&buf, "{s} {s}\n", .{ what, path[0..@min(path.len, buf.len - 16)] }) catch unreachable); + pushLog(p, std.fmt.bufPrint(&buf, "{s} {s}\n", .{ what[0..@min(what.len, 14)], path[0..@min(path.len, buf.len - 16)] }) catch unreachable); // 14, buf.len - 16 and 2 fit buf.len } /// Records `err <serial|-> <file>: <why>` for a write that was refused or @@ -250,13 +249,13 @@ pub fn noteError(p: *Pardes, req: Req, reply: Reply) void { }, }; } - var buf: [256]u8 = undefined; + var buf: [288]u8 = undefined; // A reason that names its file already (`look: no space...` from a // look) is not prefixed twice: `err 3 look: no space...`. const reason = if (why.len > file.len + 2 and std.ascii.startsWithIgnoreCase(why, file) and std.mem.startsWith(u8, why[file.len..], ": ")) why[file.len + 2 ..] else why; // A long reason is cut between words, with an ellipsis, never mid-word. const kept = pardes.Messages.clip(reason, 200); - const record = std.fmt.bufPrint(&buf, "err {s} {s}: {s}{s}\n", .{ serial, file, kept, if (kept.len < reason.len) "…" else "" }) catch unreachable; // 10 + 32 + 200 + 11 fit 256 + const record = std.fmt.bufPrint(&buf, "err {s} {s}: {s}{s}\n", .{ serial[0..@min(serial.len, 32)], file[0..@min(file.len, 32)], kept[0..@min(kept.len, 200)], if (kept.len < reason.len) "…" else "" }) catch unreachable; // 32 + 32 + 200 + 11 fit 288 for (record[0 .. record.len - 1]) |*c| if (c.* < ' ') { c.* = ' '; }; diff --git a/src/ninep/tree.zig b/src/ninep/tree.zig index 2117916d..fde0054f 100644 --- a/src/ninep/tree.zig +++ b/src/ninep/tree.zig @@ -838,7 +838,7 @@ fn open(p: *Pardes, req: Req, target: Target) Reply { // pane it made, so reading it twice answers the same one and // closing it leaves the pane alone. .new => { - const slot = p.freeSlot() orelse return failText(req.tag, E.NOSPC, std.fmt.bufPrint(&p.fs.ename, "pane/new: " ++ pardes.Messages.no_pane_slots, .{pardes.MAX_PANES}) catch unreachable); // short + const slot = p.freeSlot() orelse return failText(req.tag, E.NOSPC, std.fmt.bufPrint(&p.fs.ename, "pane/new: " ++ pardes.Messages.no_pane_slots, .{pardes.MAX_PANES}) catch unreachable); // a literal and an integer fit 320 p.fs.no_pane_slot = false; // Refused, the open's err is the one record of it (the // one rule): no msg besides. |
