]> git.donarmstrong.com Git - perltidy.git/commitdiff
Fix problem with -vtc=n and outdented long lines
authorSteve Hancock <perltidy@users.sourceforge.net>
Sun, 7 Mar 2021 15:46:51 +0000 (07:46 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sun, 7 Mar 2021 15:46:51 +0000 (07:46 -0800)
CHANGES.md
lib/Perl/Tidy/VerticalAligner.pm
local-docs/BugLog.pod

index 8e7669f783ced9e8a9e4994bd19d9dc55c345249..b9b32959dce3edc63d00541ed7f96195be456aff 100644 (file)
@@ -2,12 +2,43 @@
 
 ## 2021 01 xx
 
+    - Fixed issue git #55 regarding lack of coordination of the --break-before-xxx
+    flags and the --line-up-parens flag.
+
+    - Fixed issue git #54 regarding irregular application of the --break-before-paren
+    and similar --break-before-xxx flags, in which lists without commas were not 
+    being formatted according to these flags.
+
+    - Fixed issue git #53. A flag was added to turn off alignment of spaced function 
+    parens.  If the --space-function-paren, -sfp flag is set, a side-effect is that the
+    spaced function parens may get vertically aligned.  This can be undesirable,
+    so a new parameter '--function-paren-vertical-alignment', or '-fpva', has been
+    added to turn this vertical alignment off. The default is '-fpva', so that 
+    existing formatting is not changed.  Use '-nfpva' to turn off unwanted
+    vertical alignment.  To illustrate the possibilities:
+
+        # perltidy [default]
+        myfun( $aaa, $b, $cc );
+        mylongfun( $a, $b, $c );
+
+        # perltidy -sfp
+        myfun     ( $aaa, $b, $cc );
+        mylongfun ( $a, $b, $c );
+    
+        # perltidy -sfp -nfpva
+        myfun ( $aaa, $b, $cc );
+        mylongfun ( $a, $b, $c );
+
     - Fixed issue git #51, a closing qw bare paren was not being outdented when
     the -nodelete-old-newlines flag was set.
 
-    - Fixed a rare problem with -lp formatting which could cause alternating 
-    output states.  Except for some very deeply nested data structures,
-    most scripts formatted with this option will not be changed.
+    - Fixed numerous edge cases involving unusual parameter combinations which
+      could cause alternating output states.  Most scripts will not be
+      changed by these fixes.
+
+    - A more complete list of updates is at
+
+           https://github.com/perltidy/perltidy/blob/master/local-docs/BugLog.pod
 
 ## 2021 01 11
 
index 3100eda019eeac8aec399afa5edd4538b4d3db12..9bcf23181b4cbf15d9cc0451ee4b2dd8309cb630 100644 (file)
@@ -4787,6 +4787,7 @@ sub get_output_line_number {
         # perl527/(method.t.2, reg_mesg.t, mime-header.t)
 
         # handle outdenting of long lines:
+        my $is_outdented_line;
         if ($outdent_long_lines) {
             my $excess =
               $str_length -
@@ -4807,6 +4808,7 @@ sub get_output_line_number {
                 }
                 $outdented_line_count++;
                 $self->[_outdented_line_count_] = $outdented_line_count;
+                $is_outdented_line = 1;
             }
         }
 
@@ -5075,8 +5077,10 @@ sub get_output_line_number {
             }
         }
 
-        # write or cache this line
-        if ( !$open_or_close || $side_comment_length > 0 ) {
+        # write or cache this line ...
+        # fix for case b999: do not cache an outdented line
+        if ( !$open_or_close || $side_comment_length > 0 || $is_outdented_line )
+        {
             $self->valign_output_step_C( $line, $leading_space_count, $level,
                 $Kend );
         }
index 348eaaac80030786f0f0c11cf597e01985e630da..972949f05d56125d02d93dd25629edc7d930077f 100644 (file)
@@ -2,6 +2,30 @@
 
 =over 4
 
+=item B<Fix problem with -vtc=n and outdented long lines>
+
+Random testing produced an issue with -vtc=1 and an outdented long
+line.  The parameters for b999 are
+
+    --maximum-line-length=75
+    --paren-vertical-tightness-closing=1
+
+File 'b999.in' state 1 is
+
+                while ( $line =~
+    s/^([^\t]*)(\t+)/$1.(" " x ((length($2)<<3)-(length($1)&7)))/e
+                  )
+
+and state 2 is
+
+                while ( $line =~
+    s/^([^\t]*)(\t+)/$1.(" " x ((length($2)<<3)-(length($1)&7)))/e)
+
+The problem was fixed by turning off caching for outdented long lines.
+This fixes case b999.
+
+7 Mar 2021.
+
 =item B<Fix problem with combination -lp and -wbb='='>
 
 Random testing produced case b932 in which the combination -lp and -wbb='='
@@ -29,7 +53,7 @@ check the -wba flag setting.
 
 This update fixes case b932.
 
-7 Mar 2021.
+7 Mar 2021, 63129c3.
 
 =item B<Fix edge formatting cases with parameter -bbx=2>