]> git.donarmstrong.com Git - perltidy.git/commitdiff
fix issue with -lp -vmll -ci<2 (b1267)
authorSteve Hancock <perltidy@users.sourceforge.net>
Fri, 3 Dec 2021 17:01:35 +0000 (09:01 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Fri, 3 Dec 2021 17:01:35 +0000 (09:01 -0800)
dev-bin/run_convergence_tests.pl.data
lib/Perl/Tidy/Formatter.pm

index 3f1bc44c92e2e8ba507dfa5a9d07ace21dc2c8a8..b1e48b43f0610290bbbf16a919051b69b98d4038 100644 (file)
@@ -8427,6 +8427,31 @@ function(
 --square-bracket-tightness=2
 --variable-maximum-line-length
 
+==> b1267.in <==
+# S1
+    foreach (
+        grep
+        ( $self->{_unique_nodes}->{$_}
+            > 1,
+            keys
+            %{ $self->{_unique_nodes} } )
+    )
+# S2
+    foreach (
+        grep
+        ( $self->{_unique_nodes}->{$_}
+            > 1,
+            keys %{
+                $self->{_unique_nodes}
+            } )
+    )
+
+==> b1267.par <==
+--continuation-indentation=0
+--line-up-parentheses
+--maximum-line-length=30
+--variable-maximum-line-length
+
 ==> b131.in <==
         unless
           ( open( SCORE, "+>>$Score_File" ) )
index 8bf3933746430893650ee164f4d3239889b6dbd4..04aada48dd7b0eae5e3daaa9668b8364f0c9ac12 100644 (file)
@@ -1482,6 +1482,7 @@ EOM
     #--------------------------------------------------------------
     # The combination -lp -iob -vmll -bbx=2 can be unstable (b1266)
     #--------------------------------------------------------------
+    # The -vmll and -lp parameters do not really work well together.
     # To avoid instabilities, we will change any -bbx=2 to -bbx=1 (stable).
     # NOTE: we could make this more precise by looking at any exclusion
     # flags for -lp, and allowing -bbx=2 for excluded types.
@@ -1498,10 +1499,23 @@ EOM
         }
         if (@changed) {
 
-            # could write warning here
+            # we could write a warning here
         }
     }
 
+    #-----------------------------------------------------------
+    # The combination -lp -vmll can be unstable if -ci<2 (b1267)
+    #-----------------------------------------------------------
+    # The -vmll and -lp parameters do not really work well together.
+    # This is a very crude fix for an unusual parameter combination.
+    if (   $rOpts->{'variable-maximum-line-length'}
+        && $rOpts->{'line-up-parentheses'}
+        && $rOpts->{'continuation-indentation'} < 2 )
+    {
+        $rOpts->{'continuation-indentation'} = 2;
+        ##Warn("Increased -ci=n to n=2 for stability with -lp and -vmll\n");
+    }
+
     %container_indentation_options = ();
     foreach my $pair (
         [ 'break-before-hash-brace-and-indent',     '{' ],