File tree Expand file tree Collapse file tree 1 file changed +3
-1
lines changed
Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -582,6 +582,7 @@ pub fn findNode(doc: *const Document, offset: u32) u32 {
582582 var cur_idx : u32 = 1 ;
583583 while (cur_idx != 0 ) {
584584 const n = doc .html .nodes [cur_idx ];
585+ if (! n .kind .isElement ()) cur_idx = 0 ;
585586 if (n .open .start <= offset and n .open .end > offset ) {
586587 break ;
587588 }
@@ -599,7 +600,6 @@ pub fn findNode(doc: *const Document, offset: u32) u32 {
599600 return cur_idx ;
600601}
601602
602- // TODO this should not allocate
603603pub fn tagRanges (
604604 self : * Handler ,
605605 arena : std.mem.Allocator ,
@@ -626,6 +626,8 @@ pub fn tagRanges(
626626 }
627627 } else findNode (doc , @intCast (offset ));
628628
629+ if (node_idx == 0 ) return &.{};
630+
629631 const node = doc .html .nodes [node_idx ];
630632
631633 assert (node .kind .isElement ());
You can’t perform that action at this time.
0 commit comments