summaryrefslogtreecommitdiff
path: root/src/exec.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-28 16:45:54 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:15 -0300
commitc9d5d97e4d487b92a52d765dd9c467423ddd1de1 (patch)
tree35547658ee733fb2631a41568c682c93b5fd4746 /src/exec.zig
parentd09c1c36e4d4e1bc57aa14f5ba4c6131b6111429 (diff)
downloadpardes-c9d5d97e4d487b92a52d765dd9c467423ddd1de1.tar.gz
pardes-c9d5d97e4d487b92a52d765dd9c467423ddd1de1.zip
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 <[email protected]>
Diffstat (limited to 'src/exec.zig')
-rw-r--r--src/exec.zig11
1 files changed, 6 insertions, 5 deletions
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;