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

index f8a4a54e8952d6ad6db9e8c3be3523998536d763..58d19d65f2b1d22686a6fd6dadf21842a4e7f6b6 100644 (file)
@@ -6691,6 +6691,66 @@ my $plugin = Koha::FrameworkPlugin->new( {
 --maximum-line-length=60
 --stack-closing-paren
 
+==> b1180.in <==
+# S1
+$orders
+         = SearchOrders( {
+            ordernumber =>
+            $ordernumber
+            } ) ;
+
+# S2
+$orders= SearchOrders( {
+      ordernumber =>
+               $ordernumber
+               } );
+
+
+==> b1180.par <==
+--indent-columns=3
+--maximum-line-length=24
+--continuation-indentation=9
+--weld-nested-containers
+--want-break-before='='
+--nowant-left-space='='
+--closing-token-indentation=3
+--stack-opening-hash-brace
+--vertical-tightness-closing=2
+
+==> b1181.in <==
+# S1
+   $marc
+            = GetISBDView( {
+               'record'
+               => $marc,
+'template'
+               => 'opac',
+'framework'
+               => $framework,
+               } ) ;
+
+# S2
+   $marc= GetISBDView( {
+         'record' =>
+                  $marc,
+         'template' =>
+'opac',
+         'framework' =>
+                  $framework,
+                  } ) ;
+
+
+==> b1181.par <==
+--continuation-indentation=9
+--extended-continuation-indentation
+--indent-columns=3
+--maximum-line-length=24
+--nowant-left-space='+ <<= /= = != > -= %= -= & <<= >= * >= <<= x !~'
+--paren-vertical-tightness-closing=2
+--stack-opening-hash-brace
+--want-break-before='**= <<= -= * ^= &= =~ .= = * ||= > / = &= *= &='
+--weld-nested-containers
+
 ==> b120.in <==
 # Same as bug96
 # State 1
index 4cd319d8e3abff2783a32ba845a4f414a49bcdfa..240681fd262164ce647bbad35bb3c56d1e13a9c1 100644 (file)
@@ -7719,8 +7719,12 @@ sub weld_nested_containers {
     my $iline_outer_opening   = -1;
     my $weld_count_this_start = 0;
 
-    my $multiline_tol =
-      1 + max( $rOpts_indent_columns, $rOpts_continuation_indentation );
+    # $single_line_tol added to fix cases b1180 b1181
+    my $single_line_tol =
+      $rOpts_continuation_indentation > $rOpts_indent_columns ? 1 : 0;
+
+    my $multiline_tol = $single_line_tol + 1 +
+      max( $rOpts_indent_columns, $rOpts_continuation_indentation );
 
     my $length_to_opening_seqno = sub {
         my ($seqno) = @_;
@@ -8043,8 +8047,8 @@ EOM
             # We can use zero tolerance if it looks like we are working on an
             # existing weld.
             my $tol =
-              $is_one_line_weld || $is_multiline_weld
-              ? 0
+                $is_one_line_weld || $is_multiline_weld
+              ? $single_line_tol
               : $multiline_tol;
 
             # By how many characters does this exceed the text window?
index f1cdc77bf8ac0b8254cfc0bc8f91aad6d8249f58..e3c1596b7ab90fade73a1ca4a8db0aaf81d7da8b 100644 (file)
@@ -2,6 +2,16 @@
 
 =over 4
 
+=item B<Fix edge case of formatting instability>.
+
+Random testing with random input parameters produced cases of formatting
+instability involving welding with unusual parameter settings. This update
+makes a small tolarance adjustment to fix it.
+
+This fixes cases b1180 b1181.
+
+28 Jul 2021.
+
 =item B<Fix rare problem with formatting nested ternary statements>
 
 This update fixes an extremely rare problem in formatting nested ternary
@@ -52,7 +62,7 @@ statements, illustrated in the following snippet:
       ),
   );
 
-This fixes issue c050.
+This fixes issue c050, 63784d8.
 
 22 Jul 2021.
 
@@ -85,7 +95,7 @@ The stable state is then
 
 This fixes case b1179.
 
-21 Jul 2021.
+21 Jul 2021, 4ecc078.
 
 =item B<Fix problems with -kgb in complex structures>