]> git.donarmstrong.com Git - perltidy.git/commitdiff
Fix to keep from losing blank lines after a code-skipping section
authorSteve Hancock <perltidy@users.sourceforge.net>
Mon, 19 Jul 2021 00:00:21 +0000 (17:00 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Mon, 19 Jul 2021 00:00:21 +0000 (17:00 -0700)
CHANGES.md
lib/Perl/Tidy/Formatter.pm
local-docs/BugLog.pod

index 8c36f5997a42b2fd8612550b0b66727147d5ed4b..5f6f0af61475e2f89735f28e8852dfb56e943fc0 100644 (file)
@@ -1,5 +1,15 @@
 # Perltidy Change Log
 
+## 2021 07 17.01
+
+    - Fixed problem where a blank line following a closing code-skipping
+      comment, '#>>V', can be lost.  A workaround for the previous version
+      is to include the parameter '-mbl=2'.
+
+    - Numerous minor fixes have been made. A complete list is at:
+
+           https://github.com/perltidy/perltidy/blob/master/local-docs/BugLog.pod
+
 ## 2021 07 17
 
     - This release is being made mainly because of the next item, in which an
index cdca0f1ad2c20c1ecca8bc957a51331020dd2297..f70ea7948991868265a4ecc624e22d332b860081 100644 (file)
@@ -9654,6 +9654,14 @@ sub process_all_lines {
                 $self->[_saw_END_or_DATA_] = 1;
             }
 
+            # Patch to avoid losing blank lines after a code-skipping block;
+            # fixes case c047.  Note that the code for code-skipping is
+            # currently 'FORMAT'.  If it changes, the next line would need to
+            # be changed.
+            elsif ( $line_type eq 'FORMAT' ) {
+                $file_writer_object->reset_consecutive_blank_lines();
+            }
+
             # write unindented non-code line
             if ( !$skip_line ) {
                 $self->write_unindented_line($input_line);
index 1ca07254d416189ab272e6b562094a832c08404c..b37001c83f53b0b4a863da0e317e14cd2e556db3 100644 (file)
@@ -2,6 +2,49 @@
 
 =over 4
 
+=item B<Fix to keep from losing blank lines after a code-skipping section>
+
+A problem in the current version of perltidy is that a blank line
+after the closing code-skipping comment can be lost if there was a blank
+line before the start of the code skipping section.  For example, given
+the following code:
+
+    $x = 1;
+
+    #<<V
+    % # = ( foo => 'bar', baz => 'buz' );
+    print keys(%#), "\n";
+    #>>V
+
+    @# = ( foo, 'bar', baz, 'buz' );
+    print @#, "\n";
+
+running perltidy gives:
+
+    $x = 1;
+
+    #<<V
+    % # = ( foo => 'bar', baz => 'buz' );
+    print keys(%#), "\n";
+    #>>V
+    @# = ( foo, 'bar', baz, 'buz' );
+    print @#, "\n";
+
+Notice that the blank line after the closing comment #>>V is missing. What
+happened is that the formatter is counting blank lines and did not 'see' the
+code skipping section.  So the blank after the closing comment looked like the
+second blank in a row, so it got removed since the default is
+--maximum-consecutive-blank-lines=1.
+
+This update fixes this by resetting the counter.  This fixes case c047.
+A simple workaround until the next release is to include the parameter
+
+--maximum-consecutive-blank-lines=2, or -mbl=2.
+
+It can be removed after the next release.
+
+18 Jul 2021.
+
 =item B<Fix possible welding instability in ternary after fat comma>
 
 Random testing produced a case of formatting instability involving welding