jadelet icon indicating copy to clipboard operation
jadelet copied to clipboard

Normalize indent

Open zdenko opened this issue 4 years ago • 0 comments

This PR fixes a bug with firstIndent in the reduceLines function. The Indent token consists of two space character groups or one tab. In my previous, quick solution, I forgot to test cases with an odd number of spaces. In such cases, the parser can't detect the TagName token because of the "orphaned" space character in front. For example, in this case (symbol represents a space) :

var templateFoo = `div
⊔⊔⊔⊔⊔⊔⊔⊔⊔⊔⊔⊔⊔⊔⊔⊔⊔⊔⊔⊔span @name

there are 21 spaces. The parser will detect ten indents but will not detect LineBody token because of preceding space character (e.g., ⊔span).

To solve this, I added a rule for the TagName token, which now allows a single space character preceding an Indetifier token.

zdenko avatar Sep 18 '21 10:09 zdenko