From: Steve Hancock Date: Sun, 7 Mar 2021 13:49:10 +0000 (-0800) Subject: Fix problem with combination -lp and -wbb='=' X-Git-Tag: 20210402~21 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=63129c32929f9cd0604268d5bb28cbbb7c02b983;p=perltidy.git Fix problem with combination -lp and -wbb='=' --- diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 7585b383..444d2175 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -10842,6 +10842,10 @@ sub compare_indentation_levels { return unless defined $i && $i >= 0; + # Back up at a blank in case we need an = break. + # This is a backup fix for cases like b932. + if ( $i > 0 && $types_to_go[$i] eq 'b' ) { $i-- } + # no breaks between welded tokens return if ( $self->weld_len_right_to_go($i) ); @@ -15496,8 +15500,16 @@ sub set_continuation_breaks { my $test2 = $nesting_depth_to_go[$i_start_2]; if ( $test2 == $test1 ) { - $self->set_forced_breakpoint( - $i_start_2 - 1 ); + # Back up at a blank (fixes case b932) + my $ibr = $i_start_2 - 1; + if ( $ibr > 0 + && $types_to_go[$ibr] eq 'b' ) + { + $ibr--; + } + + $self->set_forced_breakpoint($ibr); + } } ## end if ( defined($i_start_2...)) } ## end if ( defined($item) ) diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index 0c469274..348eaaac 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -2,6 +2,35 @@ =over 4 +=item B + +Random testing produced case b932 in which the combination -lp and -wbb='=' +was not stable. + +File 'b932.par' is: + + --line-up-parentheses + --maximum-line-length=51 + --want-break-before='=' + +File 'b932.in' in the desired state is: + + my @parts + = decompose( '(\s+|/|\!|=)', + $line, undef, 1, undef, '["\']' ); + +The alternate state is + + my @parts = decompose( '(\s+|/|\!|=)', + $line, undef, 1, undef, '["\']' ); + +The problem was that the -lp code which set a line break at the equals did not +check the -wba flag setting. + +This update fixes case b932. + +7 Mar 2021. + =item B Random testing produced some cases where formatting with parameters of the form @@ -11,7 +40,7 @@ list for this particular flag to be a list with at least one non-terminal line-ending comma. This insures that the list will remain broken on subsequent iterations. This fixes cases b789 and b938. -6 Mar 2021. +6 Mar 2021, 360d669. =item B