]> git.donarmstrong.com Git - perltidy.git/commitdiff
Fix problem of conflict of -otr and -lp
authorSteve Hancock <perltidy@users.sourceforge.net>
Tue, 4 May 2021 20:36:54 +0000 (13:36 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Tue, 4 May 2021 20:36:54 +0000 (13:36 -0700)
lib/Perl/Tidy/Formatter.pm
local-docs/BugLog.pod

index a97f6b383fa94cb07bcb5b69bf212fe58c1e5760..b9f92345c03ce682bc1af47fb1cebfe9f713a314 100644 (file)
@@ -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]
           )
index 65345e92623e45e4eacaafc3102257e38db8e8f3..50809f35b3f8784ca92115fb1879746990ef10d8 100644 (file)
@@ -2,13 +2,26 @@
 
 =over 4
 
-=item B<Add option -pvtc=3, requested in rt136416>
+=item B<Fix problem of conflict of -otr and -lp>
+
+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<Add option -pvtc=3, requested in rt136417>
 
 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<Fix vertical alignment issue in rt136416>
 
@@ -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<Fix some rare issues with the -lp option>