From: Steve Hancock Date: Sat, 13 Feb 2021 14:38:40 +0000 (-0800) Subject: Add line length test for the -vtc=2 option X-Git-Tag: 20210402~50 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=f79a4f1c8e7f9f3ec9e7fd1053ed1b0c8b3a579d;p=perltidy.git Add line length test for the -vtc=2 option --- diff --git a/lib/Perl/Tidy/VerticalAligner.pm b/lib/Perl/Tidy/VerticalAligner.pm index 81d999f4..47268f42 100644 --- a/lib/Perl/Tidy/VerticalAligner.pm +++ b/lib/Perl/Tidy/VerticalAligner.pm @@ -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; diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index 5def8e90..49cf5864 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -2,13 +2,26 @@ =over 4 +=item B + +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 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 @@ -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 @@ -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