From b2fd28f367ab0c2159db83024f7d9892c9304854 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Thu, 19 Jan 2023 17:03:38 -0800 Subject: [PATCH] fix non-fatal internal fault check c177 add check to avoid creating an empty batch --- lib/Perl/Tidy/Formatter.pm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 7fe237ec..efca6d13 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -14971,13 +14971,16 @@ EOM # to add a blank. The value of the flag is as follows: # 1 => hard break, flush the batch # 2 => soft break, set breakpoint and continue building the batch - if ( $self->[_rbreak_before_Kfirst_]->{$K_first_true} ) { + # added check on max_index_to_go for c177 + if ( $max_index_to_go >= 0 + && $self->[_rbreak_before_Kfirst_]->{$K_first_true} ) + { $index_start_one_line_block = undef; if ( $self->[_rbreak_before_Kfirst_]->{$K_first_true} == 2 ) { $self->set_forced_breakpoint($max_index_to_go); } else { - $self->end_batch() if ( $max_index_to_go >= 0 ); + $self->end_batch(); } } } -- 2.39.5