]> git.donarmstrong.com Git - perltidy.git/commitdiff
Add line length test for the -vtc=2 option
authorSteve Hancock <perltidy@users.sourceforge.net>
Sat, 13 Feb 2021 14:38:40 +0000 (06:38 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sat, 13 Feb 2021 14:38:40 +0000 (06:38 -0800)
lib/Perl/Tidy/VerticalAligner.pm
local-docs/BugLog.pod

index 81d999f429d6f22945a853b97e73c0065c79aec6..47268f42f73fbd91ecf4513ab4157ef6df6dd0dc 100644 (file)
@@ -4859,6 +4859,23 @@ sub get_output_line_number {
                     }
                 }
 
+                # Do not join the lines if this produces a line too long.
+                # This prevents blinking caused by the combination -xci -pvt=2
+                # in which a one-line block alternately forms and breaks,
+                # causing -xci to alternately turn on and off (case b765). 
+                # This does not normally happen but can during stress testing.
+                if ( $gap > 0 ) {
+                    my $test_line_length =
+                      $cached_line_text_length + $gap + $str_length; 
+                    my $maximum_line_length =
+                      $self->maximum_line_length_for_level($last_level_written);
+
+                    # Add a small tolerance in the length test (fixes case b862)
+                    if ( $test_line_length > $maximum_line_length - 2 ) {
+                        $gap = -1;
+                    }
+                }
+
                 if ( $gap >= 0 && defined($seqno_beg) ) {
                     $leading_string        = $cached_line_text . ' ' x $gap;
                     $leading_string_length = $cached_line_text_length + $gap;
index 5def8e904d86934912e29c482a6de89a3186fad2..49cf586482f2faf46fdc64b7ad0529907f79d76f 100644 (file)
@@ -2,13 +2,26 @@
 
 =over 4
 
+=item B<Add line length test for the -vtc=2 option>
+
+Random testing produced a number of cases of blinking states which were caused
+when the -vtc=2 flag caused the vertical aligner to combine lines which exceeded
+the allowable line length.  These long lines were then getting reduced in size
+on every other iteration.  A line length test was added in the vertical aligner to
+prevent this.  This fixes these cases:
+
+b654 b655 b656 b657 b761 b762 b763 b764 b765 b766 b767 b768 b769 b862 b904 b905
+b906 b907 b913 b914 b915 b916 b917 b918 b919
+
+13 Feb 2021.
+
 =item B<Define left side bond strengths for unary plus and minus>
 
 Random testing produced a blinking state which was traced to the unary plus not
 having a defined strength in the line break algorithm.  This was fixed by
 setting it to be the same as the left strength of a plus.  This fixes case
 b511.
-12 Feb 2021.
+12 Feb 2021, 58a7895.
 
 =item B<Fix problem with breaking at an = sign>
 
@@ -19,7 +32,7 @@ after an equals, then that break should not have been marked as
 a good existing break point before a keyword.  This update
 fixes cases b434 b903.
 
-11 Feb 2021.
+11 Feb 2021, f9a8543.
 
 =item B<Fix conflict of -kbl=0 and essential space after =cut>
 
@@ -28,7 +41,7 @@ was alternately being deleted and added due to a conflict with
 the flag setting -keep-old-blank-lines=0.  This was resolved by giving
 prioritiy to the essential blank line after the =cut line.
 
-This fixes case b860. 11 Feb 2021.
+This fixes case b860. 11 Feb 2021, 8c13609.
 
 =item B<Do not break one-line block at here target>