]> git.donarmstrong.com Git - perltidy.git/commitdiff
fix some edge blinker cases involving -bbxi=n and -boc
authorSteve Hancock <perltidy@users.sourceforge.net>
Thu, 28 Jan 2021 23:02:59 +0000 (15:02 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Thu, 28 Jan 2021 23:02:59 +0000 (15:02 -0800)
lib/Perl/Tidy/Formatter.pm
local-docs/BugLog.pod

index eafbf1e9cdb6a7c74c70af03a89c557378b7cee8..80b48cdaae92c47eb84838de8ce815e71f646a3d 100644 (file)
@@ -7602,12 +7602,28 @@ sub adjust_container_indentation {
         my $ci = $rLL->[$KK]->[_CI_LEVEL_];
         next unless ($ci);
 
-        # and only for broken lists.
-        # Require container to span 3 or more line to avoid blinkers,
+        # Require  a container to span 3 or more lines to avoid blinkers,
         # so line difference must be 2 or more.
+        my $min_req = 2;
+
+        # But for -boc we want to see a break at an interior list comma to be
+        # sure the list stays broken.  It is sufficient to require at least two 
+        # non-blank lines within the block.
+        if ($rOpts_break_at_old_comma_breakpoints) {
+            my $iline = $rLL->[$KK]->[_LINE_INDEX_];
+            my $Knext = $self->K_next_nonblank($KK);
+            next unless ( defined($Knext) );
+            my $iline_next = $rLL->[$Knext]->[_LINE_INDEX_];
+            $min_req++ if ( $iline_next != $iline );
+        }
+
         next
           if (!$ris_broken_container->{$seqno}
-            || $ris_broken_container->{$seqno} <= 1 );
+            || $ris_broken_container->{$seqno} < $min_req );
+
+        # TBD: This should work but needs testing Otherwise, it should always
+        # be ok to do this if there are three or more interior lines.
+        # goto OK if ($ris_broken_container->{$seqno} >= 4 );
 
         # To avoid blinkers, we only want to change ci if this container
         # will definitely be broken.  We are doing this before the final
@@ -7629,9 +7645,10 @@ sub adjust_container_indentation {
             $starting_indent = $rOpts_indent_columns * $level +
               ( $ci - 1 ) * $rOpts_continuation_indentation;
 
-            if ( $flag == 2 ) {
-                $starting_indent += $rOpts_indent_columns;
-            }
+## Use old level in length estimates
+##            if ( $flag == 2 ) {
+##                $starting_indent += $rOpts_indent_columns;
+##            }
         }
         my $K_closing = $K_closing_container->{$seqno};
         next unless defined($K_closing);
@@ -7642,6 +7659,7 @@ sub adjust_container_indentation {
 
         # Always OK to change ci if the net container length exceeds maximum
         # line length
+        ## TBD: Needs TESTING: if ( $excess_length > $rOpts_continuation_indentation ) { goto OK }
         if ( $excess_length > 0 ) { goto OK }
 
         # Otherwise, not ok if -cab=2: the -cab=2 option tries to make a
@@ -19801,7 +19819,7 @@ sub set_vertical_tightness_flags {
     my $rvertical_tightness_flags = [ 0, 0, 0, 0, 0, 0 ];
 
     # The vertical tightness mechanism can add whitespace, so whitespace can
-    # continually increase if we allowed it when the -fws flag is set.  
+    # continually increase if we allowed it when the -fws flag is set.
     # See case b499 for an example.
     return $rvertical_tightness_flags if ($rOpts_freeze_whitespace);
 
index a45f7388970fcd53b537c112f94ae66a6119fd7b..319d51095e4d33116696f999e07299892a95671a 100644 (file)
@@ -2,6 +2,19 @@
 
 =over 4
 
+=item B<fix some edge blinker cases involving -bbxi=n esp. with -boc>
+
+The following cases were fixed with this update:
+
+b041 b182 b184 b366 b367 b368 b370 b371 b382 b420 b432 b438 b464 b466 b467 b468
+b500 b501 b508 b509 b510 b512 b513 b514 b515 b516 b526 b528 b529 b531 b544 b545
+b547 b548 b549 b556 b557 b568 b571 b581 b583 b584 b585 b594 b595 b596 b597 b598
+b599 b600 b601 b602 b608 b041 b182 b184 b355 b356 b366 b367 b368 b371 b420 b432
+b464 b465 b466 b467 b468 b500 b501 b508 b509 b510 b512 b513 b514 b515 b516 b526
+b528 b529 b531 b544 b545 b547 b548 b549 b556 b557 b568 b571 b581 b583 b584
+
+28 Jan 2021.
+
 =item B<fix problem with combination -cab=2 and bbhbi=n>
 
 Random testing produced a number of cases in which the combination
@@ -14,7 +27,7 @@ b046 b061 b081 b084 b089 b093 b130 b133 b135 b138 b142 b145 b147 b150 b165 b173
 b191 b211 b294 b309 b360 b363 b364 b365 b373 b386 b387 b388 b392 b437 b440 b472
 b488 b489
 
-27 Jan 2021.
+27 Jan 2021, 6d710de.
 
 =item B<fix problem with -freeze-whitespace>
 
@@ -28,7 +41,7 @@ b037 b038 b043 b059 b060 b067 b072 b215 b225 b267 b273 b276 b279 b282 b289 b292
 b300 b303 b354 b374 b375 b383 b384 b402 b403 b404 b405 b436 b441 b445 b446 b471
 b485 b498 b499
 
-27 Jan 2021.
+27 Jan 2021, 6d710de.
 
 =item B<Avoid blinking states associated with -bbpi and similar flags>