From: Steve Hancock Date: Thu, 22 Dec 2022 20:31:37 +0000 (-0800) Subject: fix b1442 X-Git-Tag: 20221112.03~9 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=aa797d78857423a5d9b529a99f946ed0db898f34;p=perltidy.git fix b1442 --- diff --git a/dev-bin/run_convergence_tests.pl.data b/dev-bin/run_convergence_tests.pl.data index 0327be92..089f297e 100644 --- a/dev-bin/run_convergence_tests.pl.data +++ b/dev-bin/run_convergence_tests.pl.data @@ -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 = $_ . '::'; diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 5b1c25b4..b0b80f33 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -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};