From: Steve Hancock <perltidy@users.sourceforge.net>
Date: Mon, 4 Oct 2021 13:45:50 +0000 (-0700)
Subject: fix rare formatting instability b1223, b1227
X-Git-Tag: 20211029~39
X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=a13514abf43df69d8af8cc87d4be79ba76008b0c;p=perltidy.git

fix rare formatting instability b1223, b1227
---

diff --git a/dev-bin/run_convergence_tests.pl.data b/dev-bin/run_convergence_tests.pl.data
index 9ce2592d..e972075c 100644
--- a/dev-bin/run_convergence_tests.pl.data
+++ b/dev-bin/run_convergence_tests.pl.data
@@ -7575,6 +7575,36 @@ print$msg,
 --weld-nested-containers
 --space-function-paren
 
+==> b1227.in <==
+# S1
+foreach$n(qw( msm ali ))
+{
+    foreach$e(qw(
+              uc16
+    ));
+}
+
+# S2
+foreach$n(qw( msm ali ))
+{   foreach$e(qw(
+              uc16
+              ) );
+}
+
+==> b1227.par <==
+
+
+
+--noadd-whitespace
+--block-brace-vertical-tightness=1
+--continuation-indentation=10
+--delete-old-whitespace
+--line-up-parentheses
+--opening-brace-on-new-line
+--paren-vertical-tightness-closing=1
+--stack-opening-paren
+--weld-nested-containers
+
 ==> b131.in <==
         unless
           ( open( SCORE, "+>>$Score_File" ) )
diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm
index 79b08273..ff1f90e5 100644
--- a/lib/Perl/Tidy/Formatter.pm
+++ b/lib/Perl/Tidy/Formatter.pm
@@ -8098,6 +8098,7 @@ sub setup_new_weld_measurements {
     # - Require blank before certain previous characters to fix b1111.
     # - Add ';' to fix case b1139
     # - Convert from '$ok_to_weld' to '$new_weld_ok' to fix b1162.
+    # - relaxed constraints for b1227
     if (   $starting_ci
         && $rOpts_line_up_parentheses
         && $rOpts_delete_old_whitespace
@@ -8110,16 +8111,20 @@ sub setup_new_weld_measurements {
         my $type_pp     = 'b';
         if ( $Kprev >= 0 ) { $type_pp = $rLL->[ $Kprev - 1 ]->[_TYPE_] }
         unless (
-               $type_prev  =~ /^[\,\.\;]/
-            || $type_prev  =~ /^[=\{\[\(\L]/ && $type_pp eq 'b'
+               $type_prev =~ /^[\,\.\;]/
+            || $type_prev =~ /^[=\{\[\(\L]/
+            && ( $type_pp eq 'b' || $type_pp eq '}' || $type_first eq 'k' )
             || $type_first =~ /^[=\,\.\;\{\[\(\L]/
             || $type_first eq '||'
-            || (   $type_first eq 'k' && $token_first eq 'if'
-                || $token_first eq 'or' )
+            || (
+                $type_first eq 'k'
+                && (   $token_first eq 'if'
+                    || $token_first eq 'or' )
+            )
           )
         {
             $msg =
-"Skipping weld: poor break with -lp and ci at type_first='$type_first' type_prev='$type_prev'\n";
+"Skipping weld: poor break with -lp and ci at type_first='$type_first' type_prev='$type_prev' type_pp=$type_pp\n";
             $new_weld_ok = 0;
         }
     }
diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod
index 707df233..adbb6fa2 100644
--- a/local-docs/BugLog.pod
+++ b/local-docs/BugLog.pod
@@ -2,7 +2,7 @@
 
 =over 4
 
-=item B<Fix issue c082, -cscw preventing deletion of closing side comments>
+=item B<Fix issue c081, -cscw preventing deletion of closing side comments>
 
 Random testing revealed a problem in which an old closing side comment was not
 being deleted when it fell below the interval specified on -csci=n
@@ -41,7 +41,7 @@ the threshold and be removed (correctly):
 But if we also add the -cscw flag (warnings) then it was not being removed.  This
 update fixes this problem (issue c081).
 
-2 Oct 2021
+2 Oct 2021, 25ef8e8
 
 =item B<Partial fix for issue git #74 on -lp at anonymous subs>