Skip to content

Commit 49e82b1

Browse files
authored
Fix empty range for ternary question mark (#215)
skip() was used after the qmark token, which resets the start position: https://github.com/tree-sitter/tree-sitter/blob/9df064c9fe31d35dc48244a6675588aee2d61a41/lib/src/lexer.c#L184
1 parent c94f0d5 commit 49e82b1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

common/scanner.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,19 +172,19 @@ static bool scan_ternary_qmark(TSLexer *lexer) {
172172
/* Optional chaining. */
173173
if (lexer->lookahead == '.') return false;
174174

175+
lexer->mark_end(lexer);
176+
lexer->result_symbol = TERNARY_QMARK;
177+
175178
/* TypeScript optional arguments contain the ?: sequence, possibly
176179
with whitespace. */
177180
for(;;) {
178181
if (!iswspace(lexer->lookahead)) break;
179-
skip(lexer);
182+
advance(lexer);
180183
}
181184
if (lexer->lookahead == ':') return false;
182185
if (lexer->lookahead == ')') return false;
183186
if (lexer->lookahead == ',') return false;
184187

185-
lexer->mark_end(lexer);
186-
lexer->result_symbol = TERNARY_QMARK;
187-
188188
if (lexer->lookahead == '.') {
189189
advance(lexer);
190190
if (iswdigit(lexer->lookahead)) return true;

0 commit comments

Comments
 (0)