From cf3283272b74e2dd1d79ad3c8afa7b00b0eceb85 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Thu, 18 Nov 2021 06:59:51 -0800 Subject: [PATCH] issue c098, update sub break_lists for revised -lp --- lib/Perl/Tidy/Formatter.pm | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 35830616..9825dfdd 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -17669,6 +17669,11 @@ EOM my $i_opening = $opening_structure_index_stack[$current_depth]; my $saw_opening_structure = ( $i_opening >= 0 ); + my $is_lp_container; + if ( $rOpts_line_up_parentheses && $saw_opening_structure ) { + $is_lp_container = $self->[_ris_lp_parent_container_] + ->{ $type_sequence_to_go[$i_opening] }; + } # this term is long if we had to break at interior commas.. my $is_long_term = $bp_count > 0; @@ -17919,8 +17924,7 @@ EOM # open up a long 'for' or 'foreach' container to allow # leading term alignment unless -lp is used. - $has_comma_breakpoints = 1 - unless $rOpts_line_up_parentheses; + $has_comma_breakpoints = 1 unless ($is_lp_container); } ## end if ( $is_long_term && ...) if ( @@ -17959,8 +17963,8 @@ EOM # the token which has been identified as starting # this indentation level. This is necessary for # proper alignment. - if ( $rOpts_line_up_parentheses && $saw_opening_structure ) - { + ##if ( $rOpts_line_up_parentheses && $saw_opening_structure ) + if ($is_lp_container) { my $item = $leading_spaces_to_go[ $i_opening + 1 ]; if ( $i_opening + 1 < $max_index_to_go && $types_to_go[ $i_opening + 1 ] eq 'b' ) @@ -18004,7 +18008,7 @@ EOM } } ## end if ( defined($i_start_2...)) } ## end if ( defined($item) ) - } ## end if ( $rOpts_line_up_parentheses...) + } ## end if ( $is_opening_container...) # break after opening structure. # note: break before closing structure will be automatic -- 2.39.5