my ( $cscw_block_comment, $closing_side_comment );
if ($rOpts_closing_side_comments) {
( $closing_side_comment, $cscw_block_comment ) =
- $self->add_closing_side_comment();
+ $self->add_closing_side_comment( $ri_first, $ri_last );
}
# flush before a long if statement to avoid unwanted alignment
sub add_closing_side_comment {
- my $self = shift;
- my $rLL = $self->[_rLL_];
+ my ( $self, $ri_first, $ri_last ) = @_;
+ my $rLL = $self->[_rLL_];
# add closing side comments after closing block braces if -csc used
my ( $closing_side_comment, $cscw_block_comment );
if ( $block_line_count <
$rOpts->{'closing-side-comment-interval'} )
{
+ # Since the line breaks have already been set, we have
+ # to remove the token from the _to_go array and also
+ # from the line range (this fixes issue c081).
+ # Note that we can only get here if -cscw has been set
+ # because otherwise the old comment is already deleted.
$token = undef;
-## FIXME: issue c081. This has not been working for some time. To make it work,
-## we also have to reduce the value if $iend in the last packed line range.
-## Otherwise, the old closing side comment will remain in the output stream.
-## $self->unstore_token_to_go()
-## if ( $types_to_go[$max_index_to_go] eq '#' );
-## $self->unstore_token_to_go()
-## if ( $types_to_go[$max_index_to_go] eq 'b' );
+ my $ibeg = $ri_first->[-1];
+ my $iend = $ri_last->[-1];
+ if ( $iend > $ibeg
+ && $iend == $max_index_to_go
+ && $types_to_go[$max_index_to_go] eq '#' )
+ {
+ $iend--;
+ $max_index_to_go--;
+ if ( $iend > $ibeg
+ && $types_to_go[$max_index_to_go] eq 'b' )
+ {
+ $iend--;
+ $max_index_to_go--;
+ }
+ $ri_last->[-1] = $iend;
+ }
}
}
}
=over 4
+=item B<Fix issue c082, -cscw preventing deletion of closing side comments>
+
+Random testing revealed a problem in which an old closing side comment was not
+being deleted when it fell below the interval specified on -csci=n
+and the -cscw flag was also set.
+
+For example, the following snippet has been formatted with -csc -csci=1. The
+interval -csci=1 insures that all blocks get side comments:
+
+ if ($x3) {
+ $zz;
+ if ($x2) {
+ if ($x1) {
+ ..;
+ } ## end if ($x1)
+ $a;
+ $b;
+ $c;
+ } ## end if ($x2)
+ } ## end if ($x3)
+
+If we then run with -csc -csci=6, the comment ## end if ($x1) will fall below
+the threshold and be removed (correctly):
+
+ if ($x3) {
+ $zz;
+ if ($x2) {
+ if ($x1) {
+ ..;
+ }
+ $a;
+ $b;
+ $c;
+ } ## end if ($x2)
+ } ## end if ($x3)
+
+But if we also add the -cscw flag (warnings) then it was not being removed. This
+update fixes this problem (issue c081).
+
+2 Oct 2021
+
=item B<Partial fix for issue git #74 on -lp at anonymous subs>
In the following snippet, the final one-line anonymous sub is not followed by a
these forced line breaks cause indentation to revert to the standard
indentation scheme.
-22 Sep 2021.
+22 Sep 2021, 4fd58f7.
=item B<Fix issues b1209 related to -vmll>
passing the maximum line length to the vertical aligner so that the calculation
is only done in the formatter. This fixes b1209.
-20 Sep 2021.
+20 Sep 2021, acf1d2d.
=item B<Fix issue b1208>