summaryrefslogtreecommitdiff
path: root/src/builtins.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/builtins.zig')
-rw-r--r--src/builtins.zig21
1 files changed, 18 insertions, 3 deletions
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");