From 78f675649461340c841e762eadb6e8b81b0048d3 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Tue, 5 Nov 2024 21:00:29 +0100 Subject: [PATCH] fix: render syntax using only the first match at a point --- src/tui/editor.zig | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/tui/editor.zig b/src/tui/editor.zig index 148fa45..3303e7f 100644 --- a/src/tui/editor.zig +++ b/src/tui/editor.zig @@ -1079,9 +1079,13 @@ pub const Editor = struct { cache: *StyleCache, root: Buffer.Root, pos_cache: PosToWidthCache, - fn cb(ctx: *@This(), range: syntax.Range, scope: []const u8, id: u32, _: usize, _: *const syntax.Node) error{Stop}!void { + last_begin: Cursor = .{}, + fn cb(ctx: *@This(), range: syntax.Range, scope: []const u8, id: u32, idx: usize, _: *const syntax.Node) error{Stop}!void { const sel_ = ctx.pos_cache.range_to_selection(range, ctx.root, ctx.self.metrics) orelse return; - + + if (idx > 0) return; + if (sel_.begin.eql(ctx.last_begin)) return; + ctx.last_begin = sel_.begin; const style_ = style_cache_lookup(ctx.theme, ctx.cache, scope, id); const style = if (style_) |sty| sty.style else return; var sel = sel_;