From 91df16bdc85f0cde9b51c0a27eae223c2dd8f42c Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Thu, 3 Oct 2024 21:05:33 -0400 Subject: [PATCH] fix(lib): ensure an unfinished state was found before removing it --- lib/src/query.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/query.c b/lib/src/query.c index c91ced48..f4efd726 100644 --- a/lib/src/query.c +++ b/lib/src/query.c @@ -4064,7 +4064,7 @@ bool ts_query_cursor_next_capture( uint32_t first_unfinished_pattern_index; uint32_t first_unfinished_state_index; bool first_unfinished_state_is_definite = false; - ts_query_cursor__first_in_progress_capture( + bool found_unfinished_state = ts_query_cursor__first_in_progress_capture( self, &first_unfinished_state_index, &first_unfinished_capture_byte, @@ -4154,7 +4154,7 @@ bool ts_query_cursor_next_capture( return true; } - if (capture_list_pool_is_empty(&self->capture_list_pool)) { + if (capture_list_pool_is_empty(&self->capture_list_pool) && found_unfinished_state) { LOG( " abandon state. index:%u, pattern:%u, offset:%u.\n", first_unfinished_state_index,