From: Steve Hancock Date: Tue, 16 Nov 2021 17:39:16 +0000 (-0800) Subject: update sub set_comma_breakpoints_do for new -lp X-Git-Tag: 20211029.01~9 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=ba210f2dfedac7e1628ec6ff3f925041378ab01a;p=perltidy.git update sub set_comma_breakpoints_do for new -lp --- diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 4901396f..374dbd90 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -18416,6 +18416,7 @@ EOM $i_last_comma = $rcomma_index->[ --$item_count - 1 ]; return if ( $item_count < 1 ); } + my $is_lp_formatting = ref( $leading_spaces_to_go[$i_first_comma] ); #--------------------------------------------------------------- # find lengths of all items in the list to calculate page layout @@ -18614,7 +18615,7 @@ EOM # items aligned. This is necessary if any of the list terms # exceeds the available space after the '('. my $need_lp_break_open = $must_break_open; - if ( $rOpts_line_up_parentheses && !$must_break_open ) { + if ( $is_lp_formatting && !$must_break_open ) { my $columns_if_unbroken = $maximum_line_length_at_level[ $levels_to_go[$i_opening_minus] ] - total_line_length( $i_opening_minus, $i_opening_paren ); @@ -18760,7 +18761,7 @@ EOM # undo some indentation # ---------------------------------------------------------------------- if ( - $rOpts_line_up_parentheses + $is_lp_formatting && ( $number_of_fields == 0 || ( $number_of_fields == 1 @@ -18976,8 +18977,8 @@ EOM # Shortcut method 1: for -lp and just one comma: # This is a no-brainer, just break at the comma. if ( - $rOpts_line_up_parentheses # -lp - && $item_count == 2 # two items, one comma + $is_lp_formatting # -lp + && $item_count == 2 # two items, one comma && !$must_break_open ) { @@ -19011,8 +19012,7 @@ EOM if ( $break_count <= 1 ) { ${$rdo_not_break_apart} = 1; } - elsif ( $rOpts_line_up_parentheses && !$need_lp_break_open ) - { + elsif ( $is_lp_formatting && !$need_lp_break_open ) { ${$rdo_not_break_apart} = 1; } } @@ -19107,8 +19107,7 @@ EOM if ( $break_count <= 1 ) { ${$rdo_not_break_apart} = 1; } - elsif ( $rOpts_line_up_parentheses && !$need_lp_break_open ) - { + elsif ( $is_lp_formatting && !$need_lp_break_open ) { ${$rdo_not_break_apart} = 1; } }