]> git.donarmstrong.com Git - perltidy.git/commitdiff
fix b1442
authorSteve Hancock <perltidy@users.sourceforge.net>
Thu, 22 Dec 2022 20:31:37 +0000 (12:31 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Thu, 22 Dec 2022 20:31:37 +0000 (12:31 -0800)
dev-bin/run_convergence_tests.pl.data
lib/Perl/Tidy/Formatter.pm

index 0327be92beb47918827b4db07a9dfb64e14d432c..089f297e522f6e2881b4d13fccda4c7827a7ff63 100644 (file)
@@ -11240,6 +11240,22 @@ $last = after (
 --paren-vertical-tightness=1
 --space-function-paren
 
+==> b1442.in <==
+                $tmpstr =
+                  sprintf ( $self->jump_to_selected_sformat(),
+                    $_, );
+
+                $tmpstr =
+                  sprintf( $self->jump_to_selected_sformat(),
+                    $_ );
+
+==> b1442.par <==
+--add-trailing-commas
+--delete-trailing-commas
+--maximum-line-length=66
+--want-trailing-commas='b'
+--space-keyword-paren
+
 ==> b1443.in <==
         @matches = map {
             $pk = $_ . '::';
index 5b1c25b45a815b074f4a6617f223e61cfe61d22e..b0b80f33e61670301a8bc19b2ab82835b8f895aa 100644 (file)
@@ -22649,12 +22649,16 @@ EOM
         if ($use_separate_first_term) {
 
             # ..set a break and update starting values
-            $use_separate_first_term = 1;
             $self->set_forced_breakpoint($i_first_comma);
+            $item_count--;
+
+            # Stop if only one item remains ($i_first_comma will be undef).
+            # Fix for b1442: use '$item_count' here instead of '$comma_count'
+            # to make the result independent of any trailing comma.
+            return if ( $item_count <= 1 );
+
             $i_opening_paren = $i_first_comma;
             $i_first_comma   = $rcomma_index->[1];
-            $item_count--;
-            return if $comma_count == 1;
             shift @{$ritem_lengths};
             shift @{$ri_term_begin};
             shift @{$ri_term_end};