From: Steve Hancock Date: Sun, 19 Feb 2023 03:17:27 +0000 (-0800) Subject: be sure output batches do not end in a blank token X-Git-Tag: 20230309~16 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=2de9fca77ada73253ace5059d660fe1553bb33a8;p=perltidy.git be sure output batches do not end in a blank token They will not be output but might cause incorrect line length calcs --- diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index dc6a782b..a96abce0 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -16790,6 +16790,11 @@ $output_str EOM }; + # Remove any trailing blank, which is possible (c192 has example) + if ( $max_index_to_go >= 0 && $types_to_go[$max_index_to_go] eq 'b' ) { + $max_index_to_go -= 1; + } + return if ( $max_index_to_go < 0 ); if ($rOpts_line_up_parentheses) { @@ -16989,7 +16994,7 @@ EOM my $imin = 0; my $imax = $max_index_to_go; - # trim any blank tokens + # trim any blank tokens - for safety, but should not be necessary if ( $types_to_go[$imin] eq 'b' ) { $imin++ } if ( $types_to_go[$imax] eq 'b' ) { $imax-- }