From: Steve Hancock Date: Sat, 5 Sep 2020 03:59:23 +0000 (-0700) Subject: add extra safety check for the -scbb -csc problem X-Git-Tag: 20200907~7 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=6f369dfc3d4d06cbf0c4faa74f8876b7f4a90f83;p=perltidy.git add extra safety check for the -scbb -csc problem --- diff --git a/lib/Perl/Tidy/VerticalAligner.pm b/lib/Perl/Tidy/VerticalAligner.pm index 7a87109f..7c799d9e 100644 --- a/lib/Perl/Tidy/VerticalAligner.pm +++ b/lib/Perl/Tidy/VerticalAligner.pm @@ -4137,6 +4137,18 @@ sub get_output_line_number { my $line = $leading_string . $str; my $line_length = $leading_string_length + $str_length; + # Safety check: be sure that a line to be cached as a stacked block + # brace line ends in the appropriate opening or closing block brace. + # This should always be the case if the caller set flags correctly. + # Code '3' is for -sobb, code '4' is for -scbb. + if ($open_or_close) { + if ( $open_or_close == 3 && $line !~ /\{\s*$/ + || $open_or_close == 4 && $line !~ /\}\s*$/ ) + { + $open_or_close = 0; + } + } + # write or cache this line if ( !$open_or_close || $side_comment_length > 0 ) { $self->valign_output_step_C( $line, $leading_space_count, $level );