]> git.donarmstrong.com Git - perltidy.git/commitdiff
slightly simplify sub set_comma_breakpoints_do
authorSteve Hancock <perltidy@users.sourceforge.net>
Tue, 23 Aug 2022 13:41:17 +0000 (06:41 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Tue, 23 Aug 2022 13:41:17 +0000 (06:41 -0700)
lib/Perl/Tidy/Formatter.pm

index 0af6ea9406948f0c299e842cb505fbaff1c9f9f4..55bbf1bc79afa018776f17b40ba62b9c1986b887 100644 (file)
@@ -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