From: Steve Hancock Date: Tue, 4 May 2021 20:36:54 +0000 (-0700) Subject: Fix problem of conflict of -otr and -lp X-Git-Tag: 20210402.01~53 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=24a0d32b77f2021f2987113c78ded351a87fccc5;p=perltidy.git Fix problem of conflict of -otr and -lp --- diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index a97f6b38..b9f92345 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -21389,6 +21389,12 @@ sub set_vertical_tightness_flags { # doing it after indentation has been set, we avoid changes # to the indentation. Actual movement of the token takes place # in sub valign_output_step_B. + + # Note added 4 May 2021: the man page suggests that the -otr flags + # are mainly for opening tokens following commas. But this seems + # to have been generalized long ago to include other situations. + # I checked the coding back to 2012 and it is essentially the same + # as here, so it is best to leave this unchanged for now. #-------------------------------------------------------------- if ( $opening_token_right{ $tokens_to_go[$ibeg_next] } @@ -21410,6 +21416,9 @@ sub set_vertical_tightness_flags { # to avoid blinking, honor the -baoo flag over the -otr flag. && $token_end ne '||' && $token_end ne '&&' + # Keep break after '=' if -lp. Fixes b964 b1040 b1062 b1083 b1089. + && !( $token_end eq '=' && $rOpts_line_up_parentheses ) + # looks bad if we align vertically with the wrong container && $tokens_to_go[$ibeg] ne $tokens_to_go[$ibeg_next] ) diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index 65345e92..50809f35 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -2,13 +2,26 @@ =over 4 -=item B +=item B + +Several random test cases produced an instability involving -otr and -lp. +In -lp mode, when an opening paren follows an equals and is far to the right, +a break is made at the equals to minimize the indentation of the next lines. +The -otr flag is a suggestion that an opening paren should be place on the right. +A check has been made to avoid this in -lp mode following an equals, since +that defeats the purpose of the original break. + +This fixes cases b964 b1040 b1062 b1083 b1089. + +4 May 2021. + +=item B A new integer option, n=3, has been added to the vertical tightness closing flags. For a container with n=3, the closing token will behave as for n=0 if the opening token is preceded by an '=' or '=>', and like n=1 otherwise. -3 May 2021. +3 May 2021, 93063a7. =item B @@ -21,7 +34,7 @@ rt#136416. The example is An update was made to reject alignments in use statements with different module names. The test file t/snippets/align35.in has more examples. -3 May 2021. +3 May 2021, 048126c. =item B