From f5f721bfef8cce1b82103e653607eea2110fc489 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 29 Sep 2026 03:41:09 -0300 Subject: Repl's unknown-language refusal names a few whole and points to the rest The refusal listed every language and was clipped to fit, ending mid-word. It now names six, those that start as the word did first (pithon: python), says how many more, and points at docs/tags.md, which lists them all. Co-Authored-By: Claude Opus 5.5 --- src/builtins.zig | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src/builtins.zig') diff --git a/src/builtins.zig b/src/builtins.zig index 87a4d022..4490482d 100644 --- a/src/builtins.zig +++ b/src/builtins.zig @@ -1075,10 +1075,25 @@ pub const Repl = struct { // Named as a code fence names it: `py`, `Python`, `sh`. 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. var w = std.Io.Writer.fixed(&buf); - w.print("Repl: no language \"{s}\"; - or one of:", .{@import("Messages.zig").clip(arg, 24)}) catch {}; - for (grammars) |g| if (g.exts.len > 0) w.print(" {s}", .{g.name}) catch break; - return c.p.reportFailure(c.id, @import("Messages.zig").clip(w.buffered(), 256)); + w.print("Repl: no language \"{s}\"; - or one like", .{@import("Messages.zig").clip(arg, 24)}) catch {}; + // 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 {}; + shown += 1; + } + }; + w.print(" ({d} more: docs/tags.md, Repl)", .{known - shown}) catch {}; + 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 "Repl"); -- cgit v1.3