From f9fba44aa990b3dd8b7888a28617635f708263b9 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Thu, 3 Nov 2022 07:15:23 -0700 Subject: [PATCH] fix b1423 --- dev-bin/run_convergence_tests.pl.data | 30 +++++++++++++++++++++ lib/Perl/Tidy/Formatter.pm | 39 ++++++++++++++------------- 2 files changed, 50 insertions(+), 19 deletions(-) diff --git a/dev-bin/run_convergence_tests.pl.data b/dev-bin/run_convergence_tests.pl.data index ef54fa6a..3ff68864 100644 --- a/dev-bin/run_convergence_tests.pl.data +++ b/dev-bin/run_convergence_tests.pl.data @@ -10843,6 +10843,36 @@ L2hos --paren-vertical-tightness=1 --weld-nested-containers +==> b1423.in <== + if ( L2hos + ->Link( $image2, + $image1, + ) + ) + { + L2hos + ->Unlink($tmp); + } + + if ( + L2hos + ->Link( $image2, + $image1, + ) + ) + { + L2hos + ->Unlink($tmp); + } + + +==> b1423.par <== +--break-at-old-comma-breakpoints +--break-at-old-method-breakpoints +--extended-line-up-parentheses +--paren-vertical-tightness=1 +--weld-nested-containers + ==> b146.in <== # State 1 diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index ffcb8a4a..d32e44f7 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -9960,6 +9960,26 @@ sub weld_nested_containers { my $token_oo = $outer_opening->[_TOKEN_]; my $token_io = $inner_opening->[_TOKEN_]; + # DO-NOT-WELD RULE 7: Do not weld if this conflicts with -bom + # Added for case b973. Moved here from below to fix b1423. + if ( !$do_not_weld_rule + && $rOpts_break_at_old_method_breakpoints + && $iline_io > $iline_oo ) + { + + foreach my $iline ( $iline_oo + 1 .. $iline_io ) { + my $rK_range = $rlines->[$iline]->{_rK_range}; + next unless defined($rK_range); + my ( $Kfirst, $Klast ) = @{$rK_range}; + next unless defined($Kfirst); + if ( $rLL->[$Kfirst]->[_TYPE_] eq '->' ) { + $do_not_weld_rule = 7; + last; + } + } + } + next if ($do_not_weld_rule); + # Turn off vertical tightness completely at possible one-line welds. # Fixes b1402. This also fixes issues b1338, b1339, b1340, b1341, # b1342, b1343, but both fixes are needed in general for good @@ -10323,25 +10343,6 @@ EOM # DO-NOT-WELD RULE 6: This has been merged into RULE 3 above. - # DO-NOT-WELD RULE 7: Do not weld if this conflicts with -bom - # (case b973) - if ( !$do_not_weld_rule - && $rOpts_break_at_old_method_breakpoints - && $iline_io > $iline_oo ) - { - - foreach my $iline ( $iline_oo + 1 .. $iline_io ) { - my $rK_range = $rlines->[$iline]->{_rK_range}; - next unless defined($rK_range); - my ( $Kfirst, $Klast ) = @{$rK_range}; - next unless defined($Kfirst); - if ( $rLL->[$Kfirst]->[_TYPE_] eq '->' ) { - $do_not_weld_rule = 7; - last; - } - } - } - if ($do_not_weld_rule) { # After neglecting a pair, we start measuring from start of point -- 2.39.5