From: Steve Hancock <perltidy@users.sourceforge.net>
Date: Sun, 21 Apr 2024 22:11:48 +0000 (-0700)
Subject: fix b1468
X-Git-Tag: 20240511~21
X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=fa023dcbb12ddf011eaa6b3aa1fc1e2d02365bd8;p=perltidy.git

fix b1468
---

diff --git a/dev-bin/run_convergence_tests.pl.data b/dev-bin/run_convergence_tests.pl.data
index 3e9556ea..04663be9 100644
--- a/dev-bin/run_convergence_tests.pl.data
+++ b/dev-bin/run_convergence_tests.pl.data
@@ -12044,6 +12044,37 @@ sub new{
 --square-bracket-tightness=2
 --brace-vertical-tightness=1
 
+==> b1468.in <==
+foreach $n (
+     qw( msm ali ) )
+{    foreach $e ( qw(
+          uc16
+          ) )
+     {
+          #
+     }
+}
+
+foreach $n (
+     qw( msm ali ) )
+{
+     foreach $e ( qw(
+          uc16
+     ) )
+     {
+          #
+     }
+}
+
+==> b1468.par <==
+--maximum-line-length=21
+--indent-columns=5
+--weld-nested-containers
+--paren-vertical-tightness-closing=2
+--stack-opening-paren
+--block-brace-vertical-tightness=1
+--nodelete-old-newlines
+
 ==> b148.in <==
 # state 1
 @yydgoto=(
diff --git a/dev-bin/run_convergence_tests.pl.expect b/dev-bin/run_convergence_tests.pl.expect
index b697fe65..cbad2352 100644
--- a/dev-bin/run_convergence_tests.pl.expect
+++ b/dev-bin/run_convergence_tests.pl.expect
@@ -8167,6 +8167,27 @@ sub new{
                   transmit => 2,
             }];
 
+==> b1468 <==
+foreach $n (
+     qw( msm ali ) )
+{    foreach $e ( qw(
+          uc16
+          ) )
+     {
+          #
+     }
+}
+
+foreach $n (
+     qw( msm ali ) )
+{    foreach $e ( qw(
+          uc16
+          ) )
+     {
+          #
+     }
+}
+
 ==> b148 <==
 # state 1
 @yydgoto=(
diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm
index 626b1396..8a21ffa7 100644
--- a/lib/Perl/Tidy/Formatter.pm
+++ b/lib/Perl/Tidy/Formatter.pm
@@ -14681,7 +14681,7 @@ sub cross_check_call_args {
 
                 # Skip the warning for small lists with undercount
                 if (   $ris_mismatched_call_type->{'u'}
-                    && $shift_count >= $mismatched_arg_undercount_cutoff )
+                    && $shift_count > $mismatched_arg_undercount_cutoff )
                 {
                     my $lines_under_count = stringify_line_range($runder_count);
                     my $total             = $num_direct + $num_self;
@@ -15787,6 +15787,26 @@ sub setup_new_weld_measurements {
         }
     }
 
+    # fix c1468 - do not measure from a leading opening block brace -
+    # which is not a one-line block
+    if (   $Kref < $Kouter_opening
+        && $Kref == $Kfirst
+        && $rLL->[$Kref]->[_TOKEN_] eq '{' )
+    {
+        my $seqno_ref = $rLL->[$Kref]->[_TYPE_SEQUENCE_];
+        if ($seqno_ref) {
+            my $block_type = $self->[_rblock_type_of_seqno_]->{$seqno_ref};
+            if ($block_type) {
+                my $Kref_c   = $self->[_K_closing_container_]->{$seqno_ref};
+                my $ln_ref_o = $rLL->[$Kref]->[_LINE_INDEX_];
+                my $ln_ref_c = $rLL->[$Kref_c]->[_LINE_INDEX_];
+                if ( $ln_ref_c > $ln_ref_o ) {
+                    $Kref = $self->K_next_nonblank($Kref);
+                }
+            }
+        }
+    }
+
     # Define the starting measurements we will need
     $starting_lentot =
       $Kref <= 0 ? 0 : $rLL->[ $Kref - 1 ]->[_CUMULATIVE_LENGTH_];