Skip to content

Commit 332b518

Browse files
authored
Merge pull request #159 from aspeddro/fix-whitespace
fix: scan inline white space
2 parents e9a7b56 + fa83db1 commit 332b518

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
@@ -45,6 +45,10 @@ void tree_sitter_rescript_external_scanner_deserialize(void* state, const char *
4545

4646
static void advance(TSLexer *lexer) { lexer->advance(lexer, false); }
4747

48+
static bool is_inline_whitespace(int32_t c) {
49+
return c == ' ' || c == '\t';
50+
}
51+
4852
static void scan_whitespace(TSLexer *lexer, bool skip) {
4953
while (iswspace(lexer->lookahead) && !lexer->eof(lexer)) {
5054
lexer->advance(lexer, skip);
@@ -133,6 +137,10 @@ bool tree_sitter_rescript_external_scanner_scan(
133137
ScannerState* state = (ScannerState*)payload;
134138
const in_string = state->in_quotes || state->in_backticks;
135139

140+
while (is_inline_whitespace(lexer->lookahead) && !in_string) {
141+
advance(lexer);
142+
}
143+
136144
if (valid_symbols[TEMPLATE_CHARS]) {
137145
lexer->result_symbol = TEMPLATE_CHARS;
138146
for (bool has_content = false;; has_content = true) {

0 commit comments

Comments
 (0)