From: Steve Hancock Date: Fri, 7 Jan 2022 15:25:06 +0000 (-0800) Subject: fix b1287, poor line break within ternary X-Git-Tag: 20211029.06~26 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=770138998e8ad620ab8be914bb38d6b01aae5758;p=perltidy.git fix b1287, poor line break within ternary --- diff --git a/dev-bin/run_convergence_tests.pl.data b/dev-bin/run_convergence_tests.pl.data index 54868763..0acd8aa2 100644 --- a/dev-bin/run_convergence_tests.pl.data +++ b/dev-bin/run_convergence_tests.pl.data @@ -8789,6 +8789,50 @@ use overload --paren-vertical-tightness=2 --weld-nested-containers +==> b1287.in <== + $" < 2 ? + $_[ $/ ][ $. ] |= 1 << $" : + ( + $_[ $@[ -1 ][ 1 ] ][ $@[ -1 ][ 0 ] ] + |= 1 << $" - 2 ); + + $" < 2 ? + $_[ $/ ][ $. ] |= + 1 << $" : ( + $_[ $@[ -1 ][ 1 ] ][ $@[ -1 ][ 0 ] ] + |= 1 << $" - 2 ); + + +==> b1287.par <== +--break-after-all-operators +--continuation-indentation=8 +--maximum-line-length=36 +--opening-paren-right +--short-concatenation-item-length=3 +--show-options +--space-after-keyword='local local if if' +--nospace-for-semicolon +--space-function-paren +--nospace-keyword-paren +--space-prototype-paren=0 +--nospace-terminal-semicolon +--square-bracket-tightness=0 +--square-bracket-vertical-tightness=1 +--stack-closing-block-brace +--nostack-closing-hash-brace +--stack-closing-paren +--stack-closing-square-bracket +--nostack-opening-hash-brace +--stack-opening-paren +--stack-opening-square-bracket +--static-side-comments +--notight-secret-operators +--trim-pod +--notrim-qw +--variable-maximum-line-length +--vertical-tightness-closing=1 +--vertical-tightness=0 + ==> b1289.in <== my $sim4 = new Bio::Tools::Sim4::Results ( diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index f8bbb907..838697db 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -18369,8 +18369,10 @@ EOM $self->set_forced_breakpoint($i); - # break at previous '=' - if ( $i_equals[$depth] > 0 ) { + # Break at a previous '=', but only if it is before + # the mating '?'. Mate_index test fixes b1287. + my $ieq = $i_equals[$depth]; + if ( $ieq > 0 && $ieq < $mate_index_to_go[$i] ) { $self->set_forced_breakpoint( $i_equals[$depth] ); $i_equals[$depth] = -1;