From: Steve Hancock Date: Wed, 8 Feb 2023 14:54:35 +0000 (-0800) Subject: fix c186, c187 X-Git-Tag: 20230309~27 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=f4320dbc744867058e86c6a411b6f0593aa6b90a;p=perltidy.git fix c186, c187 Allow more iterations in recombine operation when the number of lines in the script increases significantly during formatting. In case c187, the entire input script was a single very long line. --- diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index f001c1da..df6ce281 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -18176,6 +18176,26 @@ sub break_equals { my $it_count_max = 10 + int( 1000 / ( 1 + $nmax_section ) ) + $num_sections; + # If the current script has more lines than the original script, + # then we must allow more iterations. So we increase the max + # by one iteration per additional line. Fixes c186, c187. + my $rLL = $self->[_rLL_]; + my $K_0 = $K_to_go[0]; + my $K_x = $K_to_go[$max_index_to_go]; + my $li_0 = $rLL->[$K_0]->[_LINE_INDEX_]; + my $li_x = $rLL->[$K_x]->[_LINE_INDEX_]; + + my $nlines_gain = $nmax_start - ( $li_x - $li_0 ); + if ( $nlines_gain > 0 ) { + $it_count_max += $nlines_gain; + } + + if ( DEBUG_RECOMBINE > 0 ) { + print STDERR < 1 ) { my $max = 0; print STDERR