From: Steve Hancock <perltidy@users.sourceforge.net> Date: Fri, 26 Feb 2021 16:04:25 +0000 (-0800) Subject: Add a gap calculation in line length tests with -vmll X-Git-Tag: 20210402~33 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=a643cf2dd7041a08ad2073cb4168136de66b4900;p=perltidy.git Add a gap calculation in line length tests with -vmll --- diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 1c10b85a..ec58708e 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -6914,6 +6914,28 @@ sub weld_nested_containers { my ( $Kfirst, $Klast ) = @{$rK_range}; $starting_lentot = $Kfirst <= 0 ? 0 : $rLL->[ $Kfirst - 1 ]->[_CUMULATIVE_LENGTH_]; + + # Patch to avoid blinkers, case b965: add a possible gap to the + # starting length to avoid blinking problems when the -i=n is + # large. For example, the following with -i=9 may have a gap of 6 + # between the opening paren and the next token if vertical + # tightness is set. We have to include the gap in our estimate + # because the _CUMULATIVE_LENGTH_ + # values have maximum space lengths of 1. + + # if( $codonTable + # ->is_start_codon + # (substr( $seq,0,3 ))) + + my $gap = max( + 0, + $rOpts_indent_columns - ( + $rLL->[$Kouter_opening]->[_CUMULATIVE_LENGTH_] - + $starting_lentot + ) + ); + $starting_lentot += $gap; + $starting_indent = 0; if ( !$rOpts_variable_maximum_line_length ) { my $level = $rLL->[$Kfirst]->[_LEVEL_]; diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index 9a9f2570..92bfa5ae 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -2,6 +2,13 @@ =over 4 +=item B<Add a gap calculation in line length tests with -vmll> + +This fixes case b965. The -vmll flag can produce gaps in lines which need to +be included in weld line length estimates. + +26 Feb 2021. + =item B<Update rule for spacing paren after constant function> Random testing produced an unstable state for the following snippet (case b934)