]> git.donarmstrong.com Git - perltidy.git/commitdiff
be sure output batches do not end in a blank token
authorSteve Hancock <perltidy@users.sourceforge.net>
Sun, 19 Feb 2023 03:17:27 +0000 (19:17 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sun, 19 Feb 2023 03:17:27 +0000 (19:17 -0800)
They will not be output but might cause incorrect line length calcs

lib/Perl/Tidy/Formatter.pm

index dc6a782bd94b67ac448630cdd719cc003b9bbc4b..a96abce0b650d6156c91b74da79b192491152356 100644 (file)
@@ -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-- }