]> git.donarmstrong.com Git - perltidy.git/commitdiff
fix instability with combo -lp -iob -vmll -bbx=2 (b1266)
authorSteve Hancock <perltidy@users.sourceforge.net>
Wed, 1 Dec 2021 02:22:18 +0000 (18:22 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Wed, 1 Dec 2021 02:22:18 +0000 (18:22 -0800)
dev-bin/run_convergence_tests.pl.data
lib/Perl/Tidy/Formatter.pm

index 2225dc7eb1264cc23f573eeb7e74c8a912c81e9f..3f1bc44c92e2e8ba507dfa5a9d07ace21dc2c8a8 100644 (file)
@@ -8402,6 +8402,31 @@ function(
 --maximum-line-length=41
 --variable-maximum-line-length
 
+==> b1266.in <==
+        $self->{SUMMARY} =[
+                           {
+                             'descr' => 'Total number of users using the site',
+                             'value' => commify ($total_users)
+                           }
+        ];
+
+        $self->{SUMMARY} =
+          [
+            { 'descr' => 'Total number of users using the site', 'value' => commify ($total_users) }
+          ];
+
+==> b1266.par <==
+--break-before-square-bracket=2
+--extended-continuation-indentation
+--line-up-parentheses
+--ignore-old-breakpoints
+--indent-columns=8
+--maximum-line-length=88
+--nowant-right-space='!= | * >= = - &= -= %= .= = != | += >= += >='
+--space-function-paren
+--square-bracket-tightness=2
+--variable-maximum-line-length
+
 ==> b131.in <==
         unless
           ( open( SCORE, "+>>$Score_File" ) )
index 2070e97db360d05cac4805962675e4111f4f7076..8bf3933746430893650ee164f4d3239889b6dbd4 100644 (file)
@@ -1479,6 +1479,29 @@ EOM
         $break_before_container_types{'('} = $_ if $_ && $_ > 0;
     }
 
+    #--------------------------------------------------------------
+    # The combination -lp -iob -vmll -bbx=2 can be unstable (b1266)
+    #--------------------------------------------------------------
+    # 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.
+    if (   $rOpts->{'variable-maximum-line-length'}
+        && $rOpts->{'ignore-old-breakpoints'}
+        && $rOpts->{'line-up-parentheses'} )
+    {
+        my @changed;
+        foreach my $key ( keys %break_before_container_types ) {
+            if ( $break_before_container_types{$key} == 2 ) {
+                $break_before_container_types{$key} = 1;
+                push @changed, $key;
+            }
+        }
+        if (@changed) {
+
+            # could write warning here
+        }
+    }
+
     %container_indentation_options = ();
     foreach my $pair (
         [ 'break-before-hash-brace-and-indent',     '{' ],