]> git.donarmstrong.com Git - perltidy.git/commitdiff
Add a gap calculation in line length tests with -vmll
authorSteve Hancock <perltidy@users.sourceforge.net>
Fri, 26 Feb 2021 16:04:25 +0000 (08:04 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Fri, 26 Feb 2021 16:04:25 +0000 (08:04 -0800)
lib/Perl/Tidy/Formatter.pm
local-docs/BugLog.pod

index 1c10b85a8368fdc13dfc53b9f46220ff72001bc8..ec58708e8bee52416cc0ec9d67f2d1952c0d65da 100644 (file)
@@ -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_];
index 9a9f25709b542aad76e845c12ab3c850cc89012a..92bfa5ae5caae2fb0f094d2af8053c96a5561e32 100644 (file)
@@ -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)