fix: render syntax using only the first match at a point

This commit is contained in:
CJ van den Berg 2024-11-05 21:00:29 +01:00
parent 486c6ba95e
commit 78f6756494
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -1079,9 +1079,13 @@ pub const Editor = struct {
cache: *StyleCache, cache: *StyleCache,
root: Buffer.Root, root: Buffer.Root,
pos_cache: PosToWidthCache, 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; 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_ = style_cache_lookup(ctx.theme, ctx.cache, scope, id);
const style = if (style_) |sty| sty.style else return; const style = if (style_) |sty| sty.style else return;
var sel = sel_; var sel = sel_;