From: Steve Hancock Date: Fri, 24 Dec 2021 16:35:11 +0000 (-0800) Subject: partial fix for c119, commas after list operator X-Git-Tag: 20211029.05~20 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=b2dd9593b5057fac23075fc57051af5febde23c8;p=perltidy.git partial fix for c119, commas after list operator --- diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 0dae30bd..68dc0f0c 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -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;