]> git.donarmstrong.com Git - perltidy.git/commitdiff
Skip processing -kgb* flags in lists or if -mbl=0
authorSteve Hancock <perltidy@users.sourceforge.net>
Wed, 10 Feb 2021 16:46:39 +0000 (08:46 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Wed, 10 Feb 2021 16:46:39 +0000 (08:46 -0800)
lib/Perl/Tidy/Formatter.pm
local-docs/BugLog.pod

index 43ab58db0604aff49e55e7026c69b11ed838b640..292f9603cd878a23c9b9f1fcf344cd318c7dae26 100644 (file)
@@ -8447,6 +8447,12 @@ sub keyword_group_scan {
     #     $rhash_of_desires->{$i} = 2 means we want blank line $i removed
     my $rhash_of_desires = {};
 
+    # Nothing to do if no blanks can be output. This test added to fix
+    # case b760.
+    if ( !$rOpts_maximum_consecutive_blank_lines ) {
+        return $rhash_of_desires;
+    }
+
     my $Opt_blanks_before = $rOpts->{'keyword-group-blanks-before'};   # '-kgbb'
     my $Opt_blanks_after  = $rOpts->{'keyword-group-blanks-after'};    # '-kgba'
     my $Opt_blanks_inside = $rOpts->{'keyword-group-blanks-inside'};   # '-kgbi'
@@ -8810,6 +8816,10 @@ EOM
             return $rhash_of_desires;
         }
 
+        # This is not for keywords in lists ( keyword 'my' can occur in lists,
+        # see case b760)
+        next if ( $self->is_list_by_K($K_first) );
+
         my $level    = $rLL->[$K_first]->[_LEVEL_];
         my $type     = $rLL->[$K_first]->[_TYPE_];
         my $token    = $rLL->[$K_first]->[_TOKEN_];
index d0f27066dfad16719f3794fe1b7b432dc298825a..abeeebc5d0777ca8f54a7ec68ad8930fffef69aa 100644 (file)
@@ -2,6 +2,16 @@
 
 =over 4
 
+=item B<Skip processing -kgb* flags in lists or if -maximum-consecutive-blank-lines=0>
+
+Random testing produced an alternating state which was caused by -kgb flags
+being active on keywords which were in a list rather than a code block. A check
+was added to prevent this.  Also, the -kgb* flags have no effect if no blank
+lines can be output, so a check was added for this situation.  This fixes case
+b760.
+
+10 Feb 2021.
+
 =item B<Modify tolerance in testing for welds>
 
 Random testing with unusual parameters produced some blinking weld states which
@@ -11,7 +21,7 @@ cases were fixed with this update:
 b746 b748 b749 b750 b752 b753 b754 b755 b756 b758 b759 b771 b772 b773 b774
 b782 b783 b784 b785 b786
 
-9 Feb 2021.
+9 Feb 2021, a4609ac.
 
 =item B<Modified rule for breaking lines at old commas>