From c9d5d97e4d487b92a52d765dd9c467423ddd1de1 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 28 Sep 2026 16:45:54 -0300 Subject: A REPL's language is named and found as the syntax table finds one: aliases, any case Repl took only the grammar's exact name, and a file's language was found by a case-sensitive suffix of its path, apart from the aliases a code fence already had. The aliases move to grammar_manifest with byName and byPath, which syntax, Repl and langOf share, so `Repl py` and a .PY file work. The line-by-line warning is for the python language, not an id that starts with python. Joincol's doc line was sitting on Repl. Co-Authored-By: Claude Opus 5.5 --- src/exec.zig | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/exec.zig') diff --git a/src/exec.zig b/src/exec.zig index 9a4e0a89..12934c3c 100644 --- a/src/exec.zig +++ b/src/exec.zig @@ -17,6 +17,10 @@ const themes = colors.themes; const builtins = @import("builtins.zig"); const config = @import("config.zig"); const grammars = @import("grammar_manifest.zig").all; +const python_lang = blk: { + @setEvalBranchQuota(20_000); + break :blk @import("grammar_manifest.zig").byName("python").?; +}; const pdf_enabled = panes.Pdf.enabled; const font_picker = pardes.font_picker; const hosted = pardes.hosted; @@ -387,10 +391,7 @@ pub fn replaceStillborn(p: *Pardes) void { /// A file pane's language, as grammar_manifest names it, by its index. pub fn langOf(pane: *const Pane) ?u8 { const f = pane.file orelse return null; - for (grammars, 0..) |g, i| for (g.exts) |ext| { - if (std.mem.endsWith(u8, f.path, ext)) return @intCast(i); - }; - return null; + return @intCast(@import("grammar_manifest.zig").byPath(f.path) orelse return null); } /// A bound REPL whose program is there to take input: a command pane's @@ -490,7 +491,7 @@ pub fn sendToRepl(p: *Pardes, from: usize, to: usize, text: []const u8) void { edit.typeToTty(p, to, dst, clean[0..n]); p.emitWrite(to, "\r"); // Line by line, a blank line inside a Python block ends the block. - if (!panes.Terminal.bracketedPaste(dst) and !dst.repl_warned and std.mem.startsWith(u8, id, "python") and + if (!panes.Terminal.bracketedPaste(dst) and !dst.repl_warned and (if (dst.repl) |r| r.lang == python_lang else false) and std.mem.indexOfScalar(u8, text, '\n') != null) { dst.repl_warned = true; -- cgit v1.3