summaryrefslogtreecommitdiff
path: root/src/exec.zig
diff options
context:
space:
mode:
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;