]> git.donarmstrong.com Git - perltidy.git/commitdiff
fix b1287, poor line break within ternary
authorSteve Hancock <perltidy@users.sourceforge.net>
Fri, 7 Jan 2022 15:25:06 +0000 (07:25 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Fri, 7 Jan 2022 15:25:06 +0000 (07:25 -0800)
dev-bin/run_convergence_tests.pl.data
lib/Perl/Tidy/Formatter.pm

index 5486876370512a5315a91d9962869e7f6e89c79d..0acd8aa250d2b09f59b793f96ad9ea3d849cc2e4 100644 (file)
@@ -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 (
index f8bbb90748aeeb6cc0abf6a87085ea66e1fd1341..838697db06f3e52a69b0f1f21891e6deb92e0c1a 100644 (file)
@@ -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;