]> git.donarmstrong.com Git - perltidy.git/commitdiff
Use increased line length tolerance if -ci exceeds -i
authorSteve Hancock <perltidy@users.sourceforge.net>
Sun, 14 Feb 2021 13:43:41 +0000 (05:43 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sun, 14 Feb 2021 13:43:41 +0000 (05:43 -0800)
bin/perltidy
lib/Perl/Tidy/Formatter.pm
local-docs/BugLog.pod

index 51c830b8d28a62c95fc5b14388c75675c05e6b24..830070286efbce65af723eb0daa309914359e47d 100755 (executable)
@@ -3045,7 +3045,7 @@ being forced because B<-boc> is used).  The possible values of B<n> are:
  n=1 stable: break at all commas after => if container is open,
      EXCEPT FOR one-line containers
  n=2 break at all commas after =>, BUT try to form the maximum
-     maximum one-line container lengths
+     one-line container lengths
  n=3 do not treat commas after => specially at all 
  n=4 break everything: like n=0 but ALSO break a short container with
      a => not followed by a comma when -vt=0 is used
index 48fa7f330ebf65d4fcbf134d9f98a9ca07c7c291..54d27c128e9c7fa3b29880fd4e8da5500834296f 100644 (file)
@@ -14235,10 +14235,18 @@ sub set_continuation_breaks {
     # these arrays must retain values between calls
     my ( @has_broken_sublist, @dont_align, @want_comma_break );
 
+    my $length_tol;
+
     sub initialize_scan_list {
         @dont_align         = ();
         @has_broken_sublist = ();
         @want_comma_break   = ();
+
+        # Use an increased line length tolerance when -ci > -i
+        # to avoid blinking states (case b923 and others).
+        $length_tol =
+          1 + max( 0, $rOpts_continuation_indentation - $rOpts_indent_columns );
+
         return;
     }
 
@@ -14960,11 +14968,12 @@ sub set_continuation_breaks {
                     my $i_opening_minus =
                       $self->find_token_starting_list($i_opening);
 
-                    # Note: we have to allow for one extra space after a
-                    # closing token so that we do not strand a comma or
-                    # semicolon, hence the '>=' here (oneline.t)
+                    # Note: we have to allow for at least one extra space after
+                    # closing token so that we do not strand a comma or
+                    # semicolon. (oneline.t).
                     $is_long_term =
-                      $self->excess_line_length( $i_opening_minus, $i ) >= 0;
+                      $self->excess_line_length( $i_opening_minus, $i ) >
+                      -$length_tol;
                 } ## end if ( !$is_long_term &&...)
 
                 # We've set breaks after all comma-arrows.  Now we have to
index 4471eeea1664c74f9df848e520fa319db4356521..4fc0f827d0a4e9f443da93a8b2fd3e541bfbdd58 100644 (file)
@@ -2,6 +2,18 @@
 
 =over 4
 
+=item B<Use increased line length tolerance if ci exceeds i>
+
+In testing perltidy with random input parameters, some blinking states occurred
+when the value of -ci was significantly larger than the value of -i.  (In
+actual practice, -ci is not normally set greater than -i).  This update adds a
+tolerance to line length tests which avoids this problem.  This fixes the
+following cases
+
+b775 b776 b826 b908 b910 b911 b923 b925 b926 b927
+
+14 Feb 2021.
+
 =item B<Keep space between binary plus or minus and a bareword>
 
 This update makes a space between a binary + or - and a bareword
@@ -9,14 +21,14 @@ an essential whitespace. Otherwise, they may be converted into unary
 + or - on the next pass, which can lead to blinking states.
 Fixes cases b660 b670 b780 b781 b787 b788 b790.
 
-13 Feb 2021.
+13 Feb 2021, cf414fe.
 
 =item B<Prevent breaks after unary plus and minus>
 
 Some alternating states were produced when extremely maximum line lengths
 forced a break after a unary plus or minus.  Fixes cases b670 b790.
 
-13 Feb 2021.
+13 Feb 2021, cf414fe.
 
 =item B<Add line length test for the -vtc=2 option>