to the block of a named B<sub>, but this can be changed (see B<-blaol> below).
The default is not to do this (B<i=0>).
+If the value of B<i> is greater than the limit specified with the parameter
+B<--maximum-consecutive-blank-lines=n>, it will be reduced to that value.
+
Please see the note below on using the B<-blao> and B<-blbc> options.
=item B<-blbc=i> or B<--blank-lines-before-closing-block=i>
perltidy -blao=2 -blbc=2 -blaol='*' -blbcl='*' filename
Now suppose the script continues to be developed, but at some later date we
-decide we don't want these spaces after all. we might expect that running with
+decide we don't want these spaces after all. We might expect that running with
the flags B<-blao=0> and B<-blbc=0> will undo them. However, by default
perltidy retains single blank lines, so the blank lines remain.
$ris_essential_old_breakpoint->{$Kprev} = 1;
# Back up and count length from a token like '=' or '=>' if -lp
- # is used; this fixes b520
- if ($rOpts_line_up_parentheses) {
- if ( substr( $rLL->[$Kprev]->[_TYPE_], 0, 1 ) eq '=' ) {
+ # is used (this fixes b520)
+ # ...or if a break is wanted before there (this fixes b1041).
+ my $type_prev = $rLL->[$Kprev]->[_TYPE_];
+ if ( $rOpts_line_up_parentheses
+ || $want_break_before{$type_prev} )
+ {
+ if ( substr( $type_prev, 0, 1 ) eq '=' ) {
$Kref = $Kprev;
}
}
sub grind_batch_of_CODE {
my ($self) = @_;
- my $file_writer_object = $self->[_file_writer_object_];
- my $this_batch = $self->[_this_batch_];
+ my $file_writer_object = $self->[_file_writer_object_];
+ my $rlines = $self->[_rlines_];
+ my $this_batch = $self->[_this_batch_];
$batch_count++;
my $starting_in_quote = $this_batch->[_starting_in_quote_];
# write requested number of blank lines after an opening block brace
if ( $iterm >= $imin && $types_to_go[$iterm] eq '{' ) {
- if ( $rOpts->{'blank-lines-after-opening-block'}
+ my $nblanks = $rOpts->{'blank-lines-after-opening-block'};
+ if ( $nblanks
&& $block_type_to_go[$iterm]
&& $block_type_to_go[$iterm] =~
/$blank_lines_after_opening_block_pattern/ )
{
- my $nblanks = $rOpts->{'blank-lines-after-opening-block'};
- $self->flush_vertical_aligner();
- $file_writer_object->require_blank_code_lines($nblanks);
+
+ if ( $nblanks > $rOpts_maximum_consecutive_blank_lines ) {
+ $nblanks = $rOpts_maximum_consecutive_blank_lines;
+ }
+
+ # Reduce by the existing blank count .. fixes case b1073
+ my $Kterm = $K_to_go[$iterm];
+ my $iline = $rLL->[$Kterm]->[_LINE_INDEX_] + 1;
+ while ( $nblanks > 0 ) {
+ my $line_of_tokens = $rlines->[$iline];
+ last unless defined($line_of_tokens);
+ my $line_type = $line_of_tokens->{_line_type};
+ last
+ if ( $line_type ne 'CODE'
+ || $line_of_tokens->{_code_type} ne 'BL' );
+ $nblanks--;
+ $iline++;
+ }
+
+ if ($nblanks) {
+ $self->flush_vertical_aligner();
+ $file_writer_object->require_blank_code_lines($nblanks);
+ }
}
}
}
=over 4
+=item B<Fix problem with excess blank line generation with -blao>
+
+Random testing produced some cases where excess blank lines could be generated
+with the parameter -blank-lines-after-opening-block. Case b1073 has the
+following script
+
+ sub stop {
+
+ 1;
+ }
+
+and the following parameters
+
+ --blank-lines-after-opening-block=2
+ --maximum-consecutive-blank-lines=10
+ --maximum-line-length=15
+
+When run, blank lines keep getting generated until the maximum is reached.
+This has been fixed.
+
+6 Apr 2021.
+
+
+=item B<Fix edge case involving -wn and -lp or -bbao>
+
+A change was made to a welding rule involving the -lp option or -wbb='=', and
+very short maximum line lengths. This correctly fixes case b1041. It replaces
+a fix for this case reported on 2 Apr 2021.
+
+5 Apr 2021.
+
+
=item B<Modify a condition for applying -bbx=2>
Random testing produced some edge cases in which formatting with the -bbx=2 flags,
This update fixes cases b1068 b1069 b1070 b1072 b1073 b1076.
-5 Apr 2021.
+5 Apr 2021, 16c4591.
=item B<Improve previous -wn update>
The previous update produced some problems in testing which are corrected
with this update.
-5 Apr 2021.
+5 Apr 2021, ffef089.
=item B<Fix rare convergence problem with -wn>
This fixes cases b1041 b1055.
-2 Apr 2021.
+2 Apr 2021, a8b6259.
=item B<Avoid conflict of -bli and -xci>
This fixes case b1065.
-2 Apr 2021.
+2 Apr 2021, d20ea80.
=back