@@ -278,7 +278,8 @@ class Parse<State> implements PartialParse {
278278 while ( this . ranges [ this . rangeIndex ] . to < this . parsedPos ) this . rangeIndex ++
279279 }
280280
281- emitToken ( id : number , from : number , to : number , size : number , offset : number ) {
281+ emitToken ( id : number , from : number , to : number , offset : number ) {
282+ let size = 4
282283 if ( this . ranges . length > 1 ) {
283284 offset = this . skipGapsTo ( from , offset , 1 )
284285 from += offset
@@ -287,7 +288,11 @@ class Parse<State> implements PartialParse {
287288 to += offset
288289 size += this . chunk . length - len0
289290 }
290- this . chunk . push ( id , from , to , size )
291+ let last = this . chunk . length - 4
292+ if ( size == 4 && last >= 0 && this . chunk [ last ] == id && this . chunk [ last + 2 ] == from )
293+ this . chunk [ last + 2 ] = to
294+ else
295+ this . chunk . push ( id , from , to , size )
291296 return offset
292297 }
293298
@@ -301,7 +306,7 @@ class Parse<State> implements PartialParse {
301306 let token = readToken ( streamParser . token , stream , this . state )
302307 if ( token )
303308 offset = this . emitToken ( this . lang . tokenTable . resolve ( token ) , this . parsedPos + stream . start ,
304- this . parsedPos + stream . pos , 4 , offset )
309+ this . parsedPos + stream . pos , offset )
305310 if ( stream . start > C . MaxLineLength ) break
306311 }
307312 }
0 commit comments