From: Steve Hancock Date: Thu, 11 Feb 2021 23:42:20 +0000 (-0800) Subject: Fix conflict of -kbl=0 and essential space after =cut X-Git-Tag: 20210402~53 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=8c136099e3a2d60e18dde23cd5d35ebb491f004b;p=perltidy.git Fix conflict of -kbl=0 and essential space after =cut --- diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 50ba34b2..55aff877 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -8347,21 +8347,29 @@ sub process_all_lines { # Handle blank lines if ( $CODE_type eq 'BL' ) { - # If keep-old-blank-lines is zero, we delete all - # old blank lines and let the blank line rules generate any - # needed blanks. - - # and delete lines requested by the keyword-group logic - my $kgb_keep = !( defined( $rwant_blank_line_after->{$i} ) - && $rwant_blank_line_after->{$i} == 2 ); - - # But: the keep-old-blank-lines flag has priority over kgb flags - $kgb_keep = 1 if ( $rOpts_keep_old_blank_lines == 2 ); + # Keep this blank? Start with the flag -kbl=n, where + # n=0 ignore all old blank lines + # n=1 stable: keep old blanks, but limited by -mbl=n + # n=2 keep all old blank lines, regardless of -mbl=n + # If n=0 we delete all old blank lines and let blank line + # rules generate any needed blank lines. + my $kgb_keep = $rOpts_keep_old_blank_lines; + + # Then delete lines requested by the keyword-group logic if + # allowed + if ( $kgb_keep == 1 + && defined( $rwant_blank_line_after->{$i} ) + && $rwant_blank_line_after->{$i} == 2 ) + { + $kgb_keep = 0; + } - # Do not delete a blank line following an =cut - $kgb_keep = 1 if ( $i - $i_last_POD_END < 3 ); + # But always keep a blank line following an =cut + if ( $i - $i_last_POD_END < 3 && !$kgb_keep ) { + $kgb_keep = 1; + } - if ( $rOpts_keep_old_blank_lines && $kgb_keep ) { + if ($kgb_keep) { $self->flush($CODE_type); $file_writer_object->write_blank_code_line( $rOpts_keep_old_blank_lines == 2 ); diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index 619c049f..ac9e8213 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -2,6 +2,15 @@ =over 4 +=item B + +Random testing produced a case where a blank line after an =cut +was alternately being deleted and added due to a conflict with +the flag setting -keep-old-blank-lines=0. This was resolved by giving +prioritiy to the essential blank line after the =cut line. + +This fixes case b860. 11 Feb 2021. + =item B A blinking state produced by random testing was traced to a line of coding @@ -18,7 +27,7 @@ These will now be output with the blocks intact, like this unless ($INC{$file}) { die <<"END_DIE" } -This fixes case b523. 11 Feb 2021. +This fixes case b523. 11 Feb 2021, 6d5bb74. =item B