summaryrefslogtreecommitdiff
path: root/build.zig
diff options
context:
space:
mode:
Diffstat (limited to 'build.zig')
-rw-r--r--build.zig12
1 files changed, 10 insertions, 2 deletions
diff --git a/build.zig b/build.zig
index 0e67b61e..903b7ea8 100644
--- a/build.zig
+++ b/build.zig
@@ -400,7 +400,11 @@ pub fn build(b: *std.Build) void {
if (std.mem.count(u8, backed, end_anchor) != 1) @panic("mvzr's parser changed: redo its `$` before `|` in build.zig");
var patched = std.mem.replaceOwned(u8, b.allocator, backed, end_anchor, end_before_alt) catch @panic("OOM");
// Zig 0.17 removed `**`; mvzr still has it (its PR #16 replaces it upstream).
+ // A class's range ending at `\xff` counted to 256 in a u8, an
+ // overflow (a panic in a safe build, a runaway loop in a fast one):
+ // `[\x80-\xff]` in any search took the editor down.
for ([_][3][]const u8{
+ .{ "for (c1..c2 + 1) |c_range|", "for (c1..@as(usize, c2) + 1) |c_range|", "1" },
.{ "[1]RegOp{.{ .unused = {} }} ** ops", "@splat(.{ .unused = {} })", "1" },
.{ "[1]CharSet{.{ .low = 0, .hi = 0 }} ** char_sets", "@splat(.{ .low = 0, .hi = 0 })", "1" },
.{ "\"a\" ** 2048", "&@as([2048]u8, @splat('a'))", "2" },
@@ -2101,8 +2105,12 @@ fn treeSitter(b: *std.Build, io: std.Io, target: std.Build.ResolvedTarget, c_opt
(tree_sitter_grammars == .zig and g.tier == .zig))
grammar: {
const dep = b.lazyDependency(g.dep, .{}) orelse break :grammar;
- const query = configureRead(b, io, dep.builder.root, g.query, 0x100000) catch @panic("read " ++ g.name ++ " highlights");
- ts_queries.addOption([]const u8, g.name ++ "_highlights", query);
+ const upstream = configureRead(b, io, dep.builder.root, g.query, 0x100000) catch @panic("read " ++ g.name ++ " highlights");
+ // the patterns that colour, filtered here once and not in
+ // every compile, and the whole query, the filter's test's
+ const query = std.mem.concat(b.allocator, u8, &.{ upstream, g.highlights_extra }) catch @panic("OOM");
+ ts_queries.addOption([]const u8, g.name ++ "_highlights_unfiltered", query);
+ ts_queries.addOption([]const u8, g.name ++ "_highlights", grammar_manifest.colorQuery(query, b.allocator.alloc(u8, query.len) catch @panic("OOM")));
// helix's textobject queries, vendored (vendor/queries); a
// grammar without one gets none
const objects = configureRead(b, io, b.root, "vendor/queries/" ++ g.name ++ "/textobjects.scm", 0x100000) catch "";