diff --git a/src/scanner.c b/src/scanner.c index 13060a6..9f601cf 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -174,9 +174,13 @@ bool tree_sitter_fsharp_external_scanner_scan(void *payload, TSLexer *lexer, for (;;) { if (lexer->lookahead == '\n') { - if (valid_symbols[NEWLINE] && valid_symbols[IGNORE_INDENT]) { - lexer->result_symbol = NEWLINE; - return true; + if (valid_symbols[IGNORE_INDENT]) { + if (valid_symbols[NEWLINE]) { + lexer->result_symbol = NEWLINE; + return true; + } else { + return false; + } } else { found_end_of_line = true; indent_length = 0; diff --git a/test/corpus/compiler_directive.txt b/test/corpus/compiler_directive.txt index 85d5c27..066b984 100644 --- a/test/corpus/compiler_directive.txt +++ b/test/corpus/compiler_directive.txt @@ -143,6 +143,58 @@ let f = (const (unit))))))) +================================================================================ +light compiler directive directly above expression +================================================================================ + +#light +let x = "a" +let y = 'a'.ToString(); + +if x = y then () else failwith "Failed: 1" + +-------------------------------------------------------------------------------- + +(file + (compiler_directive_decl) + (value_declaration + (function_or_value_defn + (value_declaration_left + (identifier_pattern + (long_identifier_or_op + (identifier)))) + (const + (string)))) + (value_declaration + (function_or_value_defn + (value_declaration_left + (identifier_pattern + (long_identifier_or_op + (identifier)))) + (sequential_expression + (application_expression + (dot_expression + (const + (char)) + (long_identifier_or_op + (identifier)))) + (long_identifier_or_op + (MISSING identifier))))) + (if_expression + (infix_expression + (long_identifier_or_op + (identifier)) + (infix_op) + (long_identifier_or_op + (identifier))) + (const + (unit)) + (application_expression + (long_identifier_or_op + (identifier)) + (const + (string))))) + ================================================================================ preproc_if inside expression block ================================================================================