@@ -57,8 +57,7 @@ type ElementMeta = {
5757type State = {
5858 element : MinimapElement ;
5959 elementMeta : ElementMeta | null ;
60- currentCharacterName : ElementName | null ;
61-
60+ closingTagLength : number ;
6261 x : number ;
6362 lineNumber : number ;
6463 // highlight/task/bullet point
@@ -126,7 +125,7 @@ export const calculateChunkPositions = (
126125 } ,
127126 elementMeta : null ,
128127 parentElementMeta : null ,
129- currentCharacterName : null ,
128+ closingTagLength : 0 ,
130129 x : 0 ,
131130 lineNumber : 0 ,
132131 } ;
@@ -148,13 +147,11 @@ export const calculateChunkPositions = (
148147 if ( state . elementMeta ?. noSpaces ) {
149148 state . elementMeta = null ;
150149 }
151- state . currentCharacterName = null ;
152150 } else if (
153151 ! state . elementMeta ||
154152 state . elementMeta ?. scope !== ElementScope . full_line
155153 ) {
156154 const elementName = charToElementName [ character ] ;
157- state . currentCharacterName = elementName ;
158155 if ( elementName ) {
159156 const nextCharacter = content [ i + 1 ] ;
160157 // heading
@@ -243,7 +240,9 @@ export const calculateChunkPositions = (
243240 scope : ElementScope . character ,
244241 } ;
245242 }
246- } else {
243+ }
244+ // double tag blocks
245+ else {
247246 const isHighlight = character === '=' ;
248247 const isDoubleCharacterTag =
249248 ( isHighlight && nextCharacter === '=' ) ||
@@ -262,7 +261,9 @@ export const calculateChunkPositions = (
262261 const isClosingTag =
263262 state . elementMeta ?. elementName === elementName ;
264263 if ( isClosingTag ) {
265- state . elementMeta = null ;
264+ state . closingTagLength = isDoubleCharacterTag
265+ ? 2
266+ : 1 ;
266267 } else {
267268 const scope = isHighlight
268269 ? ElementScope . multi_line
@@ -289,7 +290,7 @@ export const calculateChunkPositions = (
289290 }
290291 // fallback to highlight/task/bullet-point types
291292 else if (
292- ! state . currentCharacterName &&
293+ state . closingTagLength === 0 &&
293294 ! state . elementMeta &&
294295 state . parentElementMeta
295296 ) {
@@ -372,7 +373,18 @@ export const calculateChunkPositions = (
372373 } else {
373374 state . element . chunk += character ;
374375 }
375-
376+ if ( state . closingTagLength > 0 ) {
377+ state . closingTagLength -- ;
378+ // end of the element
379+ if ( state . closingTagLength === 0 ) {
380+ if ( state . parentElementMeta ) {
381+ state . elementMeta = state . parentElementMeta ;
382+ state . parentElementMeta = null ;
383+ } else {
384+ state . elementMeta = null ;
385+ }
386+ }
387+ }
376388 state . x ++ ;
377389 }
378390 state . element . length_chars = state . element . chunk . length ;
0 commit comments