From d88e52d12a1cfd9798808fe0ac66fff4d8d8454c Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Tue, 23 Aug 2022 06:41:17 -0700 Subject: [PATCH] slightly simplify sub set_comma_breakpoints_do --- lib/Perl/Tidy/Formatter.pm | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 0af6ea94..55bbf1bc 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -17972,26 +17972,26 @@ sub break_long_lines { #------------------------------------------------------- # ?/: rule 1 : if a break here will separate a '?' on this # line from its closing ':', then break at the '?' instead. + # But do not break a sequential chain of ?/: statements #------------------------------------------------------- - foreach my $i ( $i_begin + 1 .. $i_lowest - 1 ) { - next unless ( $tokens_to_go[$i] eq '?' ); + if ( @{$rcolon_list} && !$is_colon_chain ) { + foreach my $i ( $i_begin + 1 .. $i_lowest - 1 ) { + next unless ( $tokens_to_go[$i] eq '?' ); - # do not break if probable sequence of ?/: statements - next if ($is_colon_chain); - - # do not break if statement is broken by side comment - next - if ( $tokens_to_go[$max_index_to_go] eq '#' - && terminal_type_i( 0, $max_index_to_go ) !~ /^[\;\}]$/ ); + # do not break if statement is broken by side comment + next + if ( $tokens_to_go[$max_index_to_go] eq '#' + && terminal_type_i( 0, $max_index_to_go ) !~ /^[\;\}]$/ ); - # no break needed if matching : is also on the line - next - if ( $mate_index_to_go[$i] >= 0 - && $mate_index_to_go[$i] <= $i_next_nonblank ); + # no break needed if matching : is also on the line + next + if ( $mate_index_to_go[$i] >= 0 + && $mate_index_to_go[$i] <= $i_next_nonblank ); - $i_lowest = $i; - if ( $want_break_before{'?'} ) { $i_lowest-- } - last; + $i_lowest = $i; + if ( $want_break_before{'?'} ) { $i_lowest-- } + last; + } } # Break the line after the token with index i=$i_lowest -- 2.39.5