From: Steve Hancock Date: Sat, 27 Mar 2021 23:37:34 +0000 (-0700) Subject: Fix problems with combinations of -iob -lp X-Git-Tag: 20210402~8 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=cc946239866c5f5958806896ee03e8fd2d5ab1b0;p=perltidy.git Fix problems with combinations of -iob -lp --- diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index d3b96de4..5ad21196 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -6435,9 +6435,12 @@ sub resync_lines_and_tokens { $file_writer_object->setup_convergence_test( \@Klast_valign_code ); # Mark essential old breakpoints if combination -iob -lp is used. These - # two options do not work well together, but we can avoid turning one off by - # ignoring -iob at certain essential line breaks. Fixes b1021. + # two options do not work well together, but we can avoid turning -iob off + # by ignoring -iob at certain essential line breaks. + # Fixes cases b1021 b1023 b1034 b1048 b1049 b1050 b1056 b1058 if ( $rOpts_ignore_old_breakpoints && $rOpts_line_up_parentheses ) { + my %is_assignment_or_fat_comma = %is_assignment; + $is_assignment_or_fat_comma{'=>'} = 1; my $ris_essential_old_breakpoint = $self->[_ris_essential_old_breakpoint_]; my $iline = -1; @@ -6451,14 +6454,14 @@ sub resync_lines_and_tokens { } my ( $Kfirst_prev, $Klast_prev ) = ( $Kfirst, $Klast ); ( $Kfirst, $Klast ) = @{ $line_of_tokens->{_rK_range} }; + next unless defined($Klast_prev); - next unless defined($Klast); - my $level_first = $rLL->[$Kfirst]->[_LEVEL_]; - my $level_last = $rLL->[$Klast]->[_LEVEL_]; - my $type_last = $rLL->[$Klast]->[_TOKEN_]; + next unless defined($Kfirst); + my $type_last = $rLL->[$Klast_prev]->[_TOKEN_]; + my $type_first = $rLL->[$Kfirst]->[_TOKEN_]; next - unless ( $level_last > $level_first - || $is_closing_type{$type_last} ); + unless ( $is_assignment_or_fat_comma{$type_last} + || $is_assignment_or_fat_comma{$type_first} ); $ris_essential_old_breakpoint->{$Klast_prev} = 1; } } diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index 516392a6..9ce87071 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -2,12 +2,25 @@ =over 4 +=item B + +This is an correction to the update of 13 Mar 2021, 71adc77. Random testing +produced several additional problems with convergence involving the combination +-iob -lp. This update fixes the problem by overriding -iob at some breakpoins +which are essential to the -lp parameter. + +This update fixes these old cases: b1021 b1023 + +and these new cases: b1034 b1048 b1049 b1050 b1056 b1058 + +27 Mar 2021 + =item B The flag -lpxl=s provides control over which containers get -lp formatting. A shortcut flag -lfp is also added for limiting -lp to simple function calls. -Updated 25 Mar 2021. +Updated 25 Mar 2021, bfc00fp. =item B