From 177fc3aecfcb4b62ea99ca3d218b798376ffe9f1 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Wed, 10 Feb 2021 08:46:39 -0800 Subject: [PATCH] Skip processing -kgb* flags in lists or if -mbl=0 --- lib/Perl/Tidy/Formatter.pm | 10 ++++++++++ local-docs/BugLog.pod | 12 +++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 43ab58db..292f9603 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -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_]; diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index d0f27066..abeeebc5 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -2,6 +2,16 @@ =over 4 +=item B + +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 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 -- 2.39.5