Skip to content

Commit a0f876f

Browse files
committed
fix(scanner): support Windows line endings
1 parent 9260050 commit a0f876f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/scanner.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,14 @@ static bool scan(Scanner *scanner, TSLexer *lexer, const bool *valid_symbols) {
350350
advanced_once = true;
351351
break;
352352

353+
case '\r':
354+
advance(lexer);
355+
// Mirror `default` case behavior if this is _not_ a CRLF, otherwise fallthrough and handle newline
356+
if (lexer->lookahead != '\n') {
357+
advanced_once = true;
358+
advance(lexer);
359+
break;
360+
}
353361
case '\n':
354362
if (valid_symbols[TEXT_FRAGMENT]) {
355363
lexer->mark_end(lexer);

0 commit comments

Comments
 (0)