]> git.donarmstrong.com Git - perltidy.git/commitdiff
partial fix for c119, commas after list operator
authorSteve Hancock <perltidy@users.sourceforge.net>
Fri, 24 Dec 2021 16:35:11 +0000 (08:35 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Fri, 24 Dec 2021 16:35:11 +0000 (08:35 -0800)
lib/Perl/Tidy/Formatter.pm

index 0dae30bdd973214577231b2dcbec7e87ebf45904..68dc0f0c2a8e47edb2ca18955225822fd9d513b9 100644 (file)
@@ -17881,6 +17881,7 @@ sub break_long_lines {
         my $total_depth_variation = 0;
         my $i_old_assignment_break;
         my $depth_last = $starting_depth;
+        my $comma_follows_last_closing_token;
 
         check_for_new_minimum_depth($current_depth);
 
@@ -18274,6 +18275,9 @@ EOM
 
                 check_for_new_minimum_depth($depth);
 
+                $comma_follows_last_closing_token =
+                  $next_nonblank_type eq ',' || $next_nonblank_type eq '=>';
+
                 # force all outer logical containers to break after we see on
                 # old breakpoint
                 $has_old_logical_breakpoints[$depth] ||=
@@ -18815,8 +18819,13 @@ EOM
                 next;
             } ## end if ( $want_comma_break...)
 
-            # break after all commas above starting depth
-            if ( $depth < $starting_depth && !$dont_align[$depth] ) {
+            # Break after all commas above starting depth...
+            # But only if the last closing token was followed by a comma,
+            #   to avoid breaking a list operator (issue c119)
+            if (   $depth < $starting_depth
+                && $comma_follows_last_closing_token
+                && !$dont_align[$depth] )
+            {
                 $self->set_forced_breakpoint($i)
                   unless ( $next_nonblank_type eq '#' );
                 next;