From a643cf2dd7041a08ad2073cb4168136de66b4900 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Fri, 26 Feb 2021 08:04:25 -0800 Subject: [PATCH] Add a gap calculation in line length tests with -vmll --- lib/Perl/Tidy/Formatter.pm | 22 ++++++++++++++++++++++ local-docs/BugLog.pod | 7 +++++++ 2 files changed, 29 insertions(+) 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 + +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 Random testing produced an unstable state for the following snippet (case b934) -- 2.39.5