diff --git a/src/scanner.c b/src/scanner.c index 765c98f..5087364 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -187,8 +187,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; + } } } } else if (lexer->lookahead == 'e') { diff --git a/test/corpus/expressions.txt b/test/corpus/expressions.txt index 67949d6..c9d1f08 100644 --- a/test/corpus/expressions.txt +++ b/test/corpus/expressions.txt @@ -1608,6 +1608,8 @@ Subscript expressions myArray[42] myObj["foo"] +andd[0] +andd[1] -------------------------------------------------------------------------------- @@ -1620,7 +1622,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