]> git.donarmstrong.com Git - perltidy.git/commitdiff
fix issue b1210, very rare instability with -vmll
authorSteve Hancock <perltidy@users.sourceforge.net>
Sat, 25 Sep 2021 21:20:33 +0000 (14:20 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sat, 25 Sep 2021 21:20:33 +0000 (14:20 -0700)
dev-bin/run_convergence_tests.pl.data
lib/Perl/Tidy/Formatter.pm

index 16f538f3238323784d7bfa3213f91f71c3c71f66..235e5570b9025f09f33f29f1c284281348c1badc 100644 (file)
@@ -7433,6 +7433,29 @@ $bc[
 --vertical-tightness=1
 --weld-nested-containers
 
+==> b1210.in <==
+# S1
+@mo = ( Jan, Feb, Mar, Apr,
+        May, Jun, Jul, Aug,
+        Sep, Oct, Nov, Dec
+);
+
+# S2
+@mo =
+         ( Jan, Feb, Mar, Apr,
+        May, Jun,
+        Jul, Aug, Sep, Oct, Nov, Dec
+         );
+
+
+==> b1210.par <==
+--break-before-paren=1
+--continuation-indentation=9
+--indent-columns=7
+--line-up-parentheses
+--maximum-line-length=34
+--variable-maximum-line-length
+
 ==> b131.in <==
         unless
           ( open( SCORE, "+>>$Score_File" ) )
index 177df1f126f9a1519b2ce461e3716bffbbc81cbb..fbab11a9246a9116ca1c0b40251756eb9b71c994 100644 (file)
@@ -18213,6 +18213,25 @@ EOM
         # Number of free columns across the page width for laying out tables
         my $columns = table_columns_available($i_first_comma);
 
+        # Patch for b1210 when -vmll is set.  If we are unable to break after
+        # an opening paren, then the maximum line length for the first line
+        # will be less than the later lines.  So we use the minimum possible.
+        if (   $rOpts_variable_maximum_line_length
+            && $tokens_to_go[$i_opening_paren] eq '('
+            && @i_term_begin
+            && !$old_breakpoint_to_go[$i_opening_paren] )
+        {
+            my $ib   = $i_term_begin[0];
+            my $type = $types_to_go[$ib];
+
+            # So far, the only known instance of this problem is when
+            # a bareword follows an opening paren with -vmll
+            if ( $type eq 'w' ) {
+                my $columns2 = table_columns_available($i_opening_paren);
+                $columns = min( $columns, $columns2 );
+            }
+        }
+
         # Estimated maximum number of fields which fit this space
         # This will be our first guess
         my $number_of_fields_max =