From: Steve Hancock Date: Sun, 14 Feb 2021 13:43:41 +0000 (-0800) Subject: Use increased line length tolerance if -ci exceeds -i X-Git-Tag: 20210402~48 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=8451f2fe1cccc3d07169267d2f495523844458bb;p=perltidy.git Use increased line length tolerance if -ci exceeds -i --- diff --git a/bin/perltidy b/bin/perltidy index 51c830b8..83007028 100755 --- a/bin/perltidy +++ b/bin/perltidy @@ -3045,7 +3045,7 @@ being forced because B<-boc> is used). The possible values of B 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 diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 48fa7f33..54d27c12 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -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 + # a 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 diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index 4471eeea..4fc0f827 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -2,6 +2,18 @@ =over 4 +=item B + +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 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 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