]> git.donarmstrong.com Git - perltidy.git/commitdiff
fix formatting instability issue b1224
authorSteve Hancock <perltidy@users.sourceforge.net>
Sat, 2 Oct 2021 13:20:08 +0000 (06:20 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sat, 2 Oct 2021 13:20:08 +0000 (06:20 -0700)
dev-bin/run_convergence_tests.pl.data
lib/Perl/Tidy/Formatter.pm

index 08ddc1b55522952850b8c0d4edb7dcf5352a9766..cda2e9488b54378f792f635d7187917c80405ace 100644 (file)
@@ -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" ) )
index ab83057984722df42d711140ddd1310dd18f370d..42d8a2efdb9811fd9d70d967554e5cc16cbcdb1e 100644 (file)
@@ -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_];
         }