@@ -34,7 +34,7 @@ export class Parser {
3434 public data ! : string ;
3535 public activeState ! : StateDefinition ;
3636 public activeRange ! : Meta ;
37- public forward ! : boolean ;
37+ public forward ! : number ;
3838 public activeTag : STATE . OpenTagMeta | undefined ; // Used to reference the closest open tag
3939 public activeAttr : STATE . AttrMeta | undefined ; // Used to reference the current attribute that is being parsed
4040 public indent ! : string ; // Used to build the indent for the current concise line
@@ -73,7 +73,7 @@ export class Parser {
7373 const { activeRange, activeState } = this ;
7474 const parent = ( this . activeRange = activeRange . parent ) ;
7575 this . activeState = parent . state ;
76- this . forward = false ;
76+ this . forward = 0 ;
7777 activeRange . end = this . pos ;
7878 activeState . exit . call ( this , activeRange ) ;
7979 this . activeState . return . call ( this , activeRange , parent ) ;
@@ -285,7 +285,8 @@ export class Parser {
285285 this . data = data ;
286286 this . indent = "" ;
287287 this . textPos = - 1 ;
288- this . forward = this . isConcise = true ;
288+ this . forward = 1 ;
289+ this . isConcise = true ;
289290 this . beginMixedMode = this . endingMixedModeAtEOL = false ;
290291 this . lines = this . activeTag = this . activeAttr = undefined ;
291292
@@ -298,31 +299,28 @@ export class Parser {
298299
299300 while ( this . pos < maxPos ) {
300301 const code = data . charCodeAt ( this . pos ) ;
301- let skip = 1 ;
302302
303303 if ( code === CODE . NEWLINE ) {
304+ this . forward = 1 ;
304305 this . activeState . eol . call ( this , 1 , this . activeRange ) ;
305306 } else if (
306307 code === CODE . CARRIAGE_RETURN &&
307308 data . charCodeAt ( this . pos + 1 ) === CODE . NEWLINE
308309 ) {
310+ this . forward = 2 ;
309311 this . activeState . eol . call ( this , 2 , this . activeRange ) ;
310- skip = 2 ;
311312 } else {
313+ this . forward = 1 ;
312314 this . activeState . char . call ( this , code , this . activeRange ) ;
313315 }
314316
315- if ( this . forward ) {
316- this . pos += skip ;
317- } else {
318- this . forward = true ;
319- }
317+ this . pos += this . forward ;
320318 }
321319
322320 while ( this . pos === this . maxPos ) {
323- this . forward = true ;
321+ this . forward = 1 ;
324322 this . activeState . eof . call ( this , this . activeRange ) ;
325- if ( this . forward ) break ;
323+ if ( this . forward !== 0 ) break ;
326324 }
327325 }
328326}
0 commit comments