Skip to content

Commit

Permalink
fix: handle error recovery better for dedents in case a string start …
Browse files Browse the repository at this point in the history
…is possible (#223)
  • Loading branch information
amaanq authored Jun 30, 2023
1 parent dd3861c commit 36f9e33
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,13 @@ bool tree_sitter_python_external_scanner_scan(void *payload, TSLexer *lexer,
return true;
}

bool next_tok_is_string_start = lexer->lookahead == '\"' ||
lexer->lookahead == '\'' ||
lexer->lookahead == '`';

if ((valid_symbols[DEDENT] ||
(!valid_symbols[NEWLINE] && !valid_symbols[STRING_START] &&
(!valid_symbols[NEWLINE] &&
!(valid_symbols[STRING_START] && next_tok_is_string_start) &&
!within_brackets)) &&
indent_length < current_indent_length &&

Expand Down

0 comments on commit 36f9e33

Please sign in to comment.