From fa83db1e7928ef16d2e783d1476a2c419bc80ffa Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Thu, 10 Nov 2022 15:22:36 -0300 Subject: [PATCH] fix: scan inline white space --- src/scanner.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/scanner.c b/src/scanner.c index 9bf9fa4..5a16db1 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -45,6 +45,10 @@ void tree_sitter_rescript_external_scanner_deserialize(void* state, const char * static void advance(TSLexer *lexer) { lexer->advance(lexer, false); } +static bool is_inline_whitespace(int32_t c) { + return c == ' ' || c == '\t'; +} + static void scan_whitespace(TSLexer *lexer, bool skip) { while (iswspace(lexer->lookahead) && !lexer->eof(lexer)) { lexer->advance(lexer, skip); @@ -133,6 +137,10 @@ bool tree_sitter_rescript_external_scanner_scan( ScannerState* state = (ScannerState*)payload; const in_string = state->in_quotes || state->in_backticks; + while (is_inline_whitespace(lexer->lookahead) && !in_string) { + advance(lexer); + } + if (valid_symbols[TEMPLATE_CHARS]) { lexer->result_symbol = TEMPLATE_CHARS; for (bool has_content = false;; has_content = true) {