From: Steve Hancock Date: Fri, 22 Oct 2021 21:57:08 +0000 (-0700) Subject: fix b1230, rare formatting instability X-Git-Tag: 20211029~5 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=69c9f4b5e32f7375f4a1d506463f51aee3dab8e1;p=perltidy.git fix b1230, rare formatting instability --- diff --git a/dev-bin/run_convergence_tests.pl.data b/dev-bin/run_convergence_tests.pl.data index 4da617f1..4fb95222 100644 --- a/dev-bin/run_convergence_tests.pl.data +++ b/dev-bin/run_convergence_tests.pl.data @@ -7767,6 +7767,38 @@ $obj= {foo => sub { "bar" ; } --line-up-parentheses --maximum-line-length=67 +==> b1230.in <== +# S1 + join( + '', + map { + $_ eq "\e" ? '\M-' + : ord($_) < 32 ? '\C-' + . lc( chr( + ord($_) + 64 ) ) + : $_ + } ( split( '', $_[0] ) ) ); +# S2 + join( + '', + map { + $_ eq "\e" ? '\M-' + : ord($_) < 32 ? '\C-' + . lc( chr( + ord($_) + 64 ) ) + : $_ + } ( split( '', $_[0] ) ) + ); + +==> b1230.par <== +--continuation-indentation=6 +--line-up-parentheses +--maximum-line-length=31 +--paren-vertical-tightness-closing=2 +--variable-maximum-line-length +--vertical-tightness=2 +--weld-nested-containers + ==> b131.in <== unless ( open( SCORE, "+>>$Score_File" ) ) diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 6d3589c6..41459647 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -8494,9 +8494,14 @@ EOM # (2) the line does not exceed the allowable length if ( $iline_oo == $iline_oc ) { - # All the tokens are on one line, now check their length + # All the tokens are on one line, now check their length: + # - measure entire line if balanced + # - measure to the closing container if unbalanced (fixes b1230) + my $is_balanced = + $rLL->[$Kfirst]->[_LEVEL_] == $rLL->[$Klast]->[_LEVEL_]; + my $Kstop = $is_balanced ? $Klast : $Kouter_closing; my $excess = - $self->excess_line_length_for_Krange( $Kfirst, $Klast ); + $self->excess_line_length_for_Krange( $Kfirst, $Kstop ); # Note: coding simplified here for case b1219 $is_one_line_weld = $excess <= 0;