]> git.donarmstrong.com Git - perltidy.git/commitdiff
Fix edge case of formatting instability, b1183
authorSteve Hancock <perltidy@users.sourceforge.net>
Sat, 31 Jul 2021 12:53:39 +0000 (05:53 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sat, 31 Jul 2021 12:53:39 +0000 (05:53 -0700)
dev-bin/run_convergence_tests.pl.data
lib/Perl/Tidy/Formatter.pm
local-docs/BugLog.pod

index 2fe90564e30e920883af0cc734994f761b04ed87..134a138aba6517d1222597d9b21c6ab956b5f279 100644 (file)
@@ -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
index 0eae6b4b269085b933f41b7b309477d330d27860..ef1f6759b7b452560a4d35cce1be6799f572a55f 100644 (file)
@@ -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} ) {
index 603f7ce8a5c278f0a437c016772f286b3b547669..076b3bdbb48ec96109e7b228bcec9f1f445da2c8 100644 (file)
@@ -2,14 +2,23 @@
 
 =over 4
 
-=item B<Fix edge case of formatting instability, b1184>.
+=item B<Fix edge case of formatting instability, b1183>.
 
 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<Fix edge case of formatting instability, b1184>.
+
+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<Fix edge case of formatting instability, b1182>.
 
@@ -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<Fix rare problem with formatting nested ternary statements>