From b561000b2a2b0b0dcdfe4bd7416ee9912cf7b41b Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Sat, 6 Aug 2016 21:24:20 -0700 Subject: [PATCH] When there's no error on the stack, keep only the best version --- src/runtime/parser.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/runtime/parser.c b/src/runtime/parser.c index 930abf61..849d1300 100644 --- a/src/runtime/parser.c +++ b/src/runtime/parser.c @@ -378,6 +378,7 @@ static bool ts_parser__better_version_exists(TSParser *self, unsigned error_depth = ts_stack_error_depth(self->stack, i); if ((error_depth > my_error_depth && error_cost >= my_error_cost) || + (my_error_depth == 0 && error_cost > my_error_cost) || (error_depth == my_error_depth && error_cost >= my_error_cost + ERROR_COST_THRESHOLD)) { LOG("halt_other version:%u", i); @@ -386,6 +387,7 @@ static bool ts_parser__better_version_exists(TSParser *self, } if ((my_error_depth > error_depth && my_error_cost >= error_cost) || + (error_depth == 0 && my_error_cost > error_cost) || (my_error_depth == error_depth && my_error_cost >= error_cost + ERROR_COST_THRESHOLD)) { return true;