fix(lib): correct fix for parsing hang with ranges containing empty points

It's more correct to check the bytes of the `size` length, rather than
use the point as a condition for resetting the lexer's token start
position
This commit is contained in:
Amaan Qureshi 2024-12-25 03:19:50 -05:00
parent f3d50f273b
commit 694d636322
2 changed files with 2 additions and 4 deletions

View file

@ -424,10 +424,7 @@ void ts_lexer_finish(Lexer *self, uint32_t *lookahead_end_byte) {
// If the token ended at an included range boundary, then its end position
// will have been reset to the end of the preceding range. Reset the start
// position to match.
if (
self->token_end_position.bytes < self->token_start_position.bytes ||
point_lt(self->token_end_position.extent, self->token_start_position.extent)
) {
if (self->token_end_position.bytes < self->token_start_position.bytes) {
self->token_start_position = self->token_end_position;
}

View file

@ -157,6 +157,7 @@ static inline bool ts_subtree_can_inline(Length padding, Length size, uint32_t l
padding.bytes < TS_MAX_INLINE_TREE_LENGTH &&
padding.extent.row < 16 &&
padding.extent.column < TS_MAX_INLINE_TREE_LENGTH &&
size.bytes < TS_MAX_INLINE_TREE_LENGTH &&
size.extent.row == 0 &&
size.extent.column < TS_MAX_INLINE_TREE_LENGTH &&
lookahead_bytes < 16;