From: Steve Hancock Date: Wed, 30 Oct 2024 00:07:14 +0000 (-0700) Subject: fix b1496 X-Git-Tag: 20240903.05~10 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=b50f0d81382165bdeb63c058116e4c48b7c4c354;p=perltidy.git fix b1496 --- diff --git a/dev-bin/run_convergence_tests.pl.data b/dev-bin/run_convergence_tests.pl.data index f4f16829..4f7da854 100644 --- a/dev-bin/run_convergence_tests.pl.data +++ b/dev-bin/run_convergence_tests.pl.data @@ -12390,6 +12390,24 @@ $e_str->bind ( '' => sub {$e_hnr->tabfocus if $e_hnr->can ( 'tabfocus' ) --want-trailing-commas='h' --delete-trailing-commas +==> b1496.in <== +my @abc + = qw( a b c d e + ); + +my @abc = qw( +a b c d e ); + +==> b1496.par <== +--maximum-line-length=21 +--indent-columns=0 +--continuation-indentation=5 +--line-up-parentheses +--break-before-all-operators +--novalign-code +--break-at-trailing-comma-types='i' +--qw-as-function + ==> b156.in <== # State 1 { diff --git a/dev-bin/run_convergence_tests.pl.expect b/dev-bin/run_convergence_tests.pl.expect index 359b58c7..4ffb4ca5 100644 --- a/dev-bin/run_convergence_tests.pl.expect +++ b/dev-bin/run_convergence_tests.pl.expect @@ -8378,6 +8378,15 @@ $e_str->bind ( '<1>' => sub { cset('D', 'HilightColorFore', "\$color"); } ); +==> b1496 <== +my @abc + = qw( a b c d e + ); + +my @abc + = qw( a b c d e + ); + ==> b156 <== # State 1 { diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 2b66a3af..62232180 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -13981,9 +13981,11 @@ sub store_token { } # set flag to retain trailing comma breaks (b1493, c416) + # length check needed to ignore phantom commas (b1496) if ( $last_nonblank_code_type eq ',' && $trailing_comma_break_rules{$token} - && $Ktoken_vars == $Kfirst_old ) + && $Ktoken_vars == $Kfirst_old + && length($last_nonblank_code_token) ) { $self->[_rbreak_container_]->{$type_sequence} = 1; }