]> git.donarmstrong.com Git - perltidy.git/commitdiff
fix b1432
authorSteve Hancock <perltidy@users.sourceforge.net>
Sat, 26 Nov 2022 23:34:05 +0000 (15:34 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sat, 26 Nov 2022 23:34:05 +0000 (15:34 -0800)
dev-bin/run_convergence_tests.pl.data
lib/Perl/Tidy/Formatter.pm

index 1ec73c9b0a55dc5da1d3de1a0eecf63253073347..05994e4da17ae689a35061f79db1e5911906ae22 100644 (file)
@@ -11055,6 +11055,28 @@ my$sem=sub
 --maximum-line-length=42
 --variable-maximum-line-length
 
+==> b1432.in <==
+$last = after ( 7,
+              sub { print "not ok 3\n"; }, );
+
+$last = after (
+                7,
+                sub { print "not ok 3\n"; },
+);
+
+
+==> b1432.par <==
+--add-trailing-commas
+--continuation-indentation=8
+--delete-trailing-commas
+--extended-continuation-indentation
+--ignore-old-breakpoints
+--indent-columns=8
+--line-up-parentheses
+--maximum-line-length=45
+--space-function-paren
+--want-trailing-commas='b'
+
 ==> b146.in <==
 # State 1
 
index 55e4a9a77b9921449aae8651b178b0d3db1989cb..84344bd55b465d0d9494d806cb8d5ba0669ed7cd 100644 (file)
@@ -23720,12 +23720,26 @@ EOM
         # nothing can be done if no stack items defined for this line
         return if ( $max_lp_object_list < 0 );
 
-        # see if we have exceeded the maximum desired line length
+        # See if we have exceeded the maximum desired line length ..
         # keep 2 extra free because they are needed in some cases
         # (result of trial-and-error testing)
+        my $tol = 2;
+
+        # But reduce tol to 0 at a terminal comma; fixes b1432
+        if (   $tokens_to_go[$mx_index_to_go] eq ','
+            && $mx_index_to_go < $max_index_to_go )
+        {
+            my $in = $mx_index_to_go + 1;
+            if ( $types_to_go[$in] eq 'b' && $in < $max_index_to_go ) { $in++ }
+            if ( $is_closing_token{ $tokens_to_go[$in] } ) {
+                $tol = 0;
+            }
+        }
+
         my $spaces_needed =
           $lp_position_predictor -
-          $maximum_line_length_at_level[ $levels_to_go[$mx_index_to_go] ] + 2;
+          $maximum_line_length_at_level[ $levels_to_go[$mx_index_to_go] ] +
+          $tol;
 
         return if ( $spaces_needed <= 0 );