diff --git a/src/runtime/stack.c b/src/runtime/stack.c index 9186397f..885083e4 100644 --- a/src/runtime/stack.c +++ b/src/runtime/stack.c @@ -400,7 +400,9 @@ void ts_stack_set_last_external_token(Stack *self, StackVersion version, Tree *t unsigned ts_stack_error_cost(const Stack *self, StackVersion version) { StackHead *head = array_get(&self->heads, version); unsigned result = head->node->error_cost; - if (head->node->state == ERROR_STATE) result += ERROR_COST_PER_RECOVERY; + if (head->node->state == ERROR_STATE || head->status == StackStatusPaused) { + result += ERROR_COST_PER_RECOVERY; + } return result; } diff --git a/test/integration/real_grammars.cc b/test/integration/real_grammars.cc index 6cee7870..37465add 100644 --- a/test/integration/real_grammars.cc +++ b/test/integration/real_grammars.cc @@ -34,7 +34,6 @@ for (auto &language_name : test_languages) { TSDocument *document; const bool debug_graphs_enabled = getenv("TREE_SITTER_ENABLE_DEBUG_GRAPHS"); - before_each([&]() { record_alloc::start(); document = ts_document_new(); diff --git a/test/runtime/document_test.cc b/test/runtime/document_test.cc index 7c4bad6c..0be03657 100644 --- a/test/runtime/document_test.cc +++ b/test/runtime/document_test.cc @@ -22,6 +22,10 @@ describe("Document", [&]() { before_each([&]() { record_alloc::start(); document = ts_document_new(); + + if (getenv("TREE_SITTER_ENABLE_DEBUG_GRAPHS")) { + ts_document_print_debugging_graphs(document, true); + } }); after_each([&]() { @@ -434,7 +438,7 @@ describe("Document", [&]() { root = ts_document_root_node(document); assert_node_string_equals( root, - "(ERROR (number) (null) (UNEXPECTED 'e'))"); + "(ERROR (number) (null))"); AssertThat(ts_node_end_byte(root), Equals(input_string.size())); });