From: Steve Hancock Date: Sat, 25 Sep 2021 16:43:31 +0000 (-0700) Subject: optimize logical padding X-Git-Tag: 20211029~57 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=156c07d6a1bd831f927b6599cc2b356106616427;p=perltidy.git optimize logical padding --- diff --git a/bin/perltidy b/bin/perltidy index d54eb587..6045f3ca 100755 --- a/bin/perltidy +++ b/bin/perltidy @@ -3909,6 +3909,7 @@ to include it separately. There are a few points to note regarding one-line blocks. A one-line block is something like this, + if ( -e $file ) { print "'$file' exists\n" } where the contents within the curly braces is short enough to fit on a single line. diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 702c91e6..177df1f1 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -167,6 +167,7 @@ my ( $rOpts_indent_only, $rOpts_keep_interior_semicolons, $rOpts_line_up_parentheses, + $rOpts_logical_padding, $rOpts_maximum_consecutive_blank_lines, $rOpts_maximum_fields_per_table, $rOpts_maximum_line_length, @@ -1656,6 +1657,7 @@ EOM $rOpts_indent_only = $rOpts->{'indent-only'}; $rOpts_keep_interior_semicolons = $rOpts->{'keep-interior-semicolons'}; $rOpts_line_up_parentheses = $rOpts->{'line-up-parentheses'}; + $rOpts_logical_padding = $rOpts->{'logical-padding'}; $rOpts_maximum_consecutive_blank_lines = $rOpts->{'maximum-consecutive-blank-lines'}; $rOpts_maximum_fields_per_table = $rOpts->{'maximum-fields-per-table'}; @@ -19805,7 +19807,7 @@ sub send_lines_to_vertical_aligner { $self->set_logical_padding( $ri_first, $ri_last, $peak_batch_size, $starting_in_quote ) - if ( !$is_block_comment && $rOpts->{'logical-padding'} ); + if ( $n_last_line > 0 && $rOpts_logical_padding ); # Resum lengths. We need accurate lengths for making alignment patterns, # and we may have unmasked a semicolon which was not included at the start.