From: Steve Hancock Date: Sat, 2 Oct 2021 13:20:08 +0000 (-0700) Subject: fix formatting instability issue b1224 X-Git-Tag: 20211029~45 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=69e4d8c8aae1568c5dacd459f23dac19b50bd067;p=perltidy.git fix formatting instability issue b1224 --- diff --git a/dev-bin/run_convergence_tests.pl.data b/dev-bin/run_convergence_tests.pl.data index 08ddc1b5..cda2e948 100644 --- a/dev-bin/run_convergence_tests.pl.data +++ b/dev-bin/run_convergence_tests.pl.data @@ -7500,6 +7500,34 @@ print$msg, --continuation-indentation=1 --maximum-line-length=12 +==> b1224.in <== +# S1 + return ( $self->_testStrand ( $other, $so ) + and not( + ( $self->start () > $other->end () + or $self->end () < $other->start () + ) + ) + ) ; + +#S2 + return ($self->_testStrand ( $other, $so ) and not( ( + $self->start () > $other->end () + or $self->end () < $other->start () + ) ) + ) ; + +==> b1224.par <== +--indent-columns=2 +--line-up-parentheses +--maximum-line-length=55 +--nostack-closing-paren +--nostack-opening-paren +--vertical-tightness-closing=0 +--vertical-tightness=2 +--weld-nested-containers +--space-function-paren + ==> b131.in <== unless ( open( SCORE, "+>>$Score_File" ) ) diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index ab830579..42d8a2ef 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -8034,15 +8034,19 @@ sub setup_new_weld_measurements { # STEP 3: Now look ahead for a ternary and, if found, use it. # This fixes case b1182. + # Also look for a ')' at the same level and, if found, use it. + # This fixes case b1224. if ( $Kref < $Kouter_opening ) { my $Knext = $rLL->[$Kref]->[_KNEXT_SEQ_ITEM_]; my $level_oo = $rLL->[$Kouter_opening]->[_LEVEL_]; while ( $Knext < $Kouter_opening ) { - if ( $is_ternary{ $rLL->[$Knext]->[_TYPE_] } - && $rLL->[$Kref]->[_LEVEL_] == $level_oo ) - { - $Kref = $Knext; - last; + if ( $rLL->[$Knext]->[_LEVEL_] == $level_oo ) { + if ( $is_ternary{ $rLL->[$Knext]->[_TYPE_] } + || $rLL->[$Knext]->[_TOKEN_] eq ')' ) + { + $Kref = $Knext; + last; + } } $Knext = $rLL->[$Knext]->[_KNEXT_SEQ_ITEM_]; }