]> git.donarmstrong.com Git - perltidy.git/commitdiff
Fix git #51, closing qw paren not outdented if -ndnl is set
authorSteve Hancock <perltidy@users.sourceforge.net>
Sun, 24 Jan 2021 18:56:41 +0000 (10:56 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sun, 24 Jan 2021 18:56:41 +0000 (10:56 -0800)
CHANGES.md
lib/Perl/Tidy/Formatter.pm
local-docs/BugLog.pod

index 91a09074d119c64d0466df750a51ef9ae14402cd..8e7669f783ced9e8a9e4994bd19d9dc55c345249 100644 (file)
@@ -2,6 +2,9 @@
 
 ## 2021 01 xx
 
+    - 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.
index 6ef5b969bff6bc4a13a2d9d78000d3c9fc682214..5a51768b6134d982cb6ebce31acbbfa390896286 100644 (file)
@@ -17181,6 +17181,15 @@ sub send_lines_to_vertical_aligner {
             $type_end_next  = $rLL->[$Kend_next]->[_TYPE_];
             $ljump = $rLL->[$Kbeg_next]->[_LEVEL_] - $rLL->[$Kend]->[_LEVEL_];
         }
+        else {
+
+            # Patch for git #51, a bare closing qw paren was not outdented 
+            # if the flag '-nodelete-old-newlines is set
+            my $Kbeg_next = $self->K_next_code($Kend);
+            if ( defined($Kbeg_next) ) {
+                 $ljump = $rLL->[$Kbeg_next]->[_LEVEL_] - $rLL->[$Kend]->[_LEVEL_];
+            }
+        }
 
         # level jump at end of line for the vertical aligner:
         my $level_jump =
@@ -19138,6 +19147,11 @@ sub make_paren_name {
                 || (   $i_terminal > $ibeg
                     && $is_closing_type{ $types_to_go[$iend] } )
 
+                # Alternate Patch for git #51, isolated closing qw token not
+                # outdented if no-delete-old-newlines is set. This works, but
+                # a more general patch elsewhere fixes the real problem: ljump.
+                # || ( $seqno_qw_closing && $ibeg == $i_terminal )
+
               )
             {
                 $adjust_indentation = 1;
index 055c539d37a90ffb9f61d2185114f05573acfe82..72a60a8f4a749ad516f33f48e62542a7b8501077 100644 (file)
@@ -2,6 +2,44 @@
 
 =over 4
 
+=item B<Fix for issue git #51, closing qw paren not outdented when -ndnl is set>
+
+The problem is that a bare closing qw paren was not being outdented 
+if the flag '-nodelete-old-newlines is set. For example
+
+    # OLD (OK, outdented): perltidy -ci=4 -xci
+    {
+        modules => [
+            qw(
+                JSON
+            )
+        ],
+    }
+
+
+    # OLD (indented) : perltidy -ndnl -ci=4 -xci
+    {
+        modules => [
+            qw(
+                JSON
+                )
+        ],
+    }
+
+    # FIXED: perltidy -ndnl -ci=4 -xci
+    {
+        modules => [
+            qw(
+                JSON
+            )
+        ],
+    }
+
+The problem happened because the -ndnl flag forces each line to be written
+immediately, so the next line (which needs to be checked in this case) was not
+available when the outdent decision had to be made.  A patch to work around
+this was added 24 Jan 2021.
+
 =item B<Some issues with the -lp option>
 
 Random testing revealed some problems involving the B<-lp> option which are