diff --git a/src/scanner.c b/src/scanner.c index 3e80a79..7ffea5f 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -239,8 +239,11 @@ bool tree_sitter_rescript_external_scanner_scan( if (lexer->lookahead == 'n') { advance(lexer); if (lexer->lookahead == 'd') { - // Ignore new lines before `and` keyword (recursive definition) - in_multiline_statement = true; + advance(lexer); + if (is_whitespace(lexer->lookahead)) { + // Ignore new lines before `and` keyword (recursive definition) + in_multiline_statement = true; + } } } } diff --git a/test/corpus/expressions.txt b/test/corpus/expressions.txt index fc20174..040798f 100644 --- a/test/corpus/expressions.txt +++ b/test/corpus/expressions.txt @@ -1388,6 +1388,8 @@ Subscript expressions myArray[42] myObj["foo"] +andd[0] +andd[1] -------------------------------------------------------------------------------- @@ -1400,7 +1402,16 @@ myObj["foo"] (subscript_expression (value_identifier) (string - (string_fragment))))) + (string_fragment)))) + + (expression_statement + (subscript_expression + (value_identifier) + (number))) + (expression_statement + (subscript_expression + (value_identifier) + (number)))) ================================================================================ Variants