]> git.donarmstrong.com Git - perltidy.git/commitdiff
Fix issue b1208
authorSteve Hancock <perltidy@users.sourceforge.net>
Sat, 18 Sep 2021 15:20:35 +0000 (08:20 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sat, 18 Sep 2021 15:20:35 +0000 (08:20 -0700)
CHANGES.md
MANIFEST
dev-bin/run_convergence_tests.pl.data
lib/Perl/Tidy/Formatter.pm
local-docs/BugLog.pod

index c33ffbff42f85df044f7f0eb971b41c88d5138f6..fc69d3df404e8f7780db2d3db54b7ff7a1342c5c 100644 (file)
@@ -2,6 +2,10 @@
 
 ## 2021 07 17.02
 
+    - Fix issue git #73, the -nfpva flag was not working correctly.
+      Some unwanted vertical alignments of spaced function perens
+      were being made.
+
     - Update the man pages to clarify the flags -valign and -novalign
       for turning vertical alignment on and off (issue git #72).
       Added parameters -vc -vsc -vbc for separately turning off vertical
index e190c9189d98130f9db321f6bd7375a907fb3ef8..3e7239d7d3f8d13cb5311847c25609434f162b85 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -76,6 +76,7 @@ t/snippets21.t
 t/snippets22.t
 t/snippets23.t
 t/snippets24.t
+t/snippets25.t
 t/snippets3.t
 t/snippets4.t
 t/snippets5.t
index 4af2d966323f121405518e4b04a324304dc2a648..a6e77fa06cbcc346a5ac6288fff763ad913d7418 100644 (file)
@@ -7383,6 +7383,36 @@ if (
 ==> b1207.par <==
 --nowant-right-space='x'
 
+==> b1208.in <==
+# S1
+
+    my $home = (
+          $^O =~ /mswin32/i
+        ? $ENV{HOME}
+        : (
+            eval { ( getpwuid($>) )[7]; } ## end eval
+                     || $ENV{HOME}
+        )
+    );
+
+# S2
+
+    my $home = (
+          $^O =~ /mswin32/i
+        ? $ENV{HOME}
+        : (
+            eval {
+                ( getpwuid($>) )[7];
+            } ## end eval
+                     || $ENV{HOME}
+        )
+    );
+
+==> b1208.par <==
+--continuation-indentation=9
+--extended-continuation-indentation
+--maximum-line-length=54
+
 ==> b131.in <==
         unless
           ( open( SCORE, "+>>$Score_File" ) )
index 68bf5bfde68961f63c96896469da8567268d842e..1b0035dd3a72c665b357c277c41192aba9f31030 100644 (file)
@@ -1,4 +1,4 @@
-#####################################################################
+####################################################################
 #
 # The Perl::Tidy::Formatter package adds indentation, whitespace, and
 # line breaks to the token stream
@@ -11551,8 +11551,9 @@ EOM
             # Get next nonblank on this line
             my $next_nonblank_token      = '';
             my $next_nonblank_token_type = 'b';
+            my $Knnb;
             if ( $Ktoken_vars < $K_last ) {
-                my $Knnb = $Ktoken_vars + 1;
+                $Knnb = $Ktoken_vars + 1;
                 if (   $rLL->[$Knnb]->[_TYPE_] eq 'b'
                     && $Knnb < $K_last )
                 {
@@ -11695,6 +11696,14 @@ EOM
                 # If there is a pending one-line block ..
                 if ( $index_start_one_line_block != UNDEFINED_INDEX ) {
 
+                    # Fix for b1208: if a side comment follows this closing
+                    # brace then we must include its length in the length test.
+                    # Assume a minimum of 1 blank space to the comment.
+                    my $added_length =
+                      $side_comment_follows
+                      ? 1 + $rLL->[$Knnb]->[_TOKEN_LENGTH_]
+                      : 0;
+
                     # we have to terminate it if..
                     if (
 
@@ -11702,7 +11711,7 @@ EOM
                         # initial estimate). note: must allow 1 space for this
                         # token
                         $self->excess_line_length( $index_start_one_line_block,
-                            $max_index_to_go ) >= 0
+                            $max_index_to_go ) + $added_length >= 0
 
                         # or if it has too many semicolons
                         || (   $semicolons_before_block_self_destruct == 0
index 20e9de855b94537acbb4e9bf4b74aae1b033a7b3..6d9682fe2ba27f63b6036f2ef2a7ba99bf955091 100644 (file)
@@ -2,6 +2,34 @@
 
 =over 4
 
+=item B<Fix issue b1208>
+
+Test with random parameters produced a formatting instability which could be
+triggered when there is a short line length limit and there is a long side
+comment on the closing brace of a sort/map/grep/eval block.  The problem was
+due to not correctly including the length of the side comment when testing to
+see if the block could fit on one line.  This update fixes issue b1208.
+
+18 Sep 2021.
+
+=item B<Fix issue git #73>
+
+The -nfpva parameter was not working correctly for functions called with
+pointers.  For example
+
+    # OLD: perltidy -sfp -nfpva
+    $self->method                ( 'parameter_0', 'parameter_1' );
+    $self->method_with_long_name ( 'parameter_0', 'parameter_1' );
+
+    # FIXED: perltidy -sfp -nfpva
+    $self->method ( 'parameter_0', 'parameter_1' );
+    $self->method_with_long_name ( 'parameter_0', 'parameter_1' );
+
+The problem had to do with how the pointer tokens '->' are represented internally
+and has been fixed.
+
+17 Sep 2021.
+
 =item B<Fix unusual parsing error b1207>
 
 Testing with random parameters produced another instability caused by misparsing
@@ -24,7 +52,7 @@ Note in particular the different treatment of the first two print statements.
 
 This update fixes case b1207.
 
-15 Sep 2021.
+15 Sep 2021, 107586f.
 
 =item B<Fix formatting instability b1206>