From 2de9fca77ada73253ace5059d660fe1553bb33a8 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Sat, 18 Feb 2023 19:17:27 -0800 Subject: [PATCH] be sure output batches do not end in a blank token They will not be output but might cause incorrect line length calcs --- lib/Perl/Tidy/Formatter.pm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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-- } -- 2.39.5