From: Steve Hancock Date: Sat, 31 Jul 2021 12:53:39 +0000 (-0700) Subject: Fix edge case of formatting instability, b1183 X-Git-Tag: 20210717.02~69 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=055650be6ad91e041bfb7b58ae4f218ba23eb317;p=perltidy.git Fix edge case of formatting instability, b1183 --- diff --git a/dev-bin/run_convergence_tests.pl.data b/dev-bin/run_convergence_tests.pl.data index 2fe90564..134a138a 100644 --- a/dev-bin/run_convergence_tests.pl.data +++ b/dev-bin/run_convergence_tests.pl.data @@ -6855,6 +6855,30 @@ $orders= SearchOrders( { --maximum-line-length=55 --weld-nested-containers +==> b1183.in <== +# S1 +is ( + ref( + Koha::Patron::Discharge::request ( { borrowernumber => $patron->{borrowernumber} } ) + ), + 'Koha::Schema::Result::Discharge', + 'Discharge request sent' ); + +# S2 +is ( + ref( Koha::Patron::Discharge::request ( { borrowernumber => $patron->{borrowernumber} } ) + ), + 'Koha::Schema::Result::Discharge', + 'Discharge request sent' ); + +==> b1183.par <== +--continuation-indentation=8 +--extended-continuation-indentation +--line-up-parentheses +--maximum-line-length=99 +--vertical-tightness=1 +--weld-nested-containers + ==> b1184.in <== # S1 ok( ( Win32::GetFullPathName( substr diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 0eae6b4b..ef1f6759 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -5060,6 +5060,8 @@ EOM # remains fixed for the rest of this iteration. $self->respace_tokens(); + $self->set_excluded_lp_containers(); + $self->find_multiline_qw(); $self->keep_old_line_breaks(); @@ -5072,8 +5074,6 @@ EOM $self->adjust_indentation_levels(); - $self->set_excluded_lp_containers(); - # Finishes formatting and write the result to the line sink. # Eventually this call should just change the 'rlines' data according to the # new line breaks and then return so that we can do an internal iteration @@ -7733,6 +7733,8 @@ sub weld_nested_containers { my $K_opening_container = $self->[_K_opening_container_]; my $K_closing_container = $self->[_K_closing_container_]; + my $ris_excluded_lp_container = $self->[_ris_excluded_lp_container_]; + # Find nested pairs of container tokens for any welding. my $rnested_pairs = $self->find_nested_pairs(); @@ -7904,6 +7906,7 @@ EOM # An existing one-line weld is a line in which # (1) the containers are all on one line, and # (2) the line does not exceed the allowable length, and + # (3) is not created with -lp -vt=n instead of welding # This flag is used to avoid creating blinkers. # FIX1: Changed 'excess_length_to_K' to 'excess_length_of_line' # to get exact lengths and fix b604 b605. @@ -7948,6 +7951,17 @@ EOM else { $is_one_line_weld = 1; } + + # If an apparent one-line weld might have been created by + # -vt and -lp, then do not mark as a one-line weld. + # This condition added to fix b1183. + if ( $is_one_line_weld + && $rOpts_line_up_parentheses + && $opening_vertical_tightness{$token_oo} + && !$ris_excluded_lp_container->{$outer_seqno} ) + { + $is_one_line_weld = 0; + } } } @@ -8036,7 +8050,6 @@ EOM # The effect of this change on typical code is very minimal. Sometimes # it may take a second iteration to converge, but this gives protection # against blinking. - if ( !$do_not_weld_rule && !$is_one_line_weld && $iline_ic == $iline_io ) @@ -8167,9 +8180,9 @@ EOM if ($do_not_weld_rule) { - # After neglecting a pair, we start measuring from start of point io - # ... but not if previous type does not like to be separated from - # its container (fixes case b1184) + # After neglecting a pair, we start measuring from start of point + # io ... but not if previous type does not like to be separated + # from its container (fixes case b1184) my $Kprev = $self->K_previous_nonblank($Kinner_opening); my $type_prev = defined($Kprev) ? $rLL->[$Kprev]->[_TYPE_] : 'w'; if ( !$has_tight_paren{$type_prev} ) { diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index 603f7ce8..076b3bdb 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -2,14 +2,23 @@ =over 4 -=item B. +=item B. Testing with random parameters produced a case of welding instability involving parameters -wn, -vt=n, -lp. This update fixes the problem. +This fixes case b1183. + +30 Jul 2021. + +=item B. + +Testing with random parameters produced a case of welding instability involving +a tripple weld with parameters -wn, -vt=n, -lp. This update fixes the problem. + This fixes case b1184. -28 Jul 2021. +29 Jul 2021. =item B. @@ -29,7 +38,7 @@ makes a small tolarance adjustment to fix it. This fixes cases b1180 b1181. -28 Jul 2021. +28 Jul 2021, b38ccfc. =item B