From: Steve Hancock Date: Mon, 29 Nov 2021 13:37:06 +0000 (-0800) Subject: prevent unwanted recombinations after = X-Git-Tag: 20211029.03~1 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=7d86cac3cfec8520b55fbb4fb955c6c116674c90;p=perltidy.git prevent unwanted recombinations after = --- diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 42fe521a..80a32399 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -13049,6 +13049,11 @@ sub compare_indentation_levels { # - If a break is made after an opening token, then a break will # also be made before the corresponding closing token. + # Returns '$i_nonblank': + # = index of the token after which the breakpoint was actually placed + # = undef if breakpoint was not set. + my $i_nonblank; + if ( !defined($i) || $i < 0 ) { # Calls with bad index $i are harmless but waste time and should @@ -13063,7 +13068,7 @@ sub compare_indentation_levels { } # Break after token $i - my ($i_nonblank) = $self->set_forced_breakpoint_AFTER($i); + $i_nonblank = $self->set_forced_breakpoint_AFTER($i); # If we break at an opening container..break at the closing my $set_closing; @@ -13094,7 +13099,7 @@ EOM print STDOUT $msg; }; - return; + return $i_nonblank; } sub set_forced_breakpoint_AFTER { @@ -17374,7 +17379,14 @@ sub break_long_lines { $ibr--; } if ( $ibr >= 0 ) { - $self->set_forced_breakpoint($ibr); + my $i_nonblank = $self->set_forced_breakpoint($ibr); + + # Crude patch to prevent sub recombine_breakpoints from undoing + # this break, especially after an '='. It will leave old + # breakpoints alone. See c098/x045 for some examples. + if ( defined($i_nonblank) ) { + $old_breakpoint_to_go[$i_nonblank] = 1; + } } return; };