From b50f0d81382165bdeb63c058116e4c48b7c4c354 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Tue, 29 Oct 2024 17:07:14 -0700 Subject: [PATCH] fix b1496 --- dev-bin/run_convergence_tests.pl.data | 18 ++++++++++++++++++ dev-bin/run_convergence_tests.pl.expect | 9 +++++++++ lib/Perl/Tidy/Formatter.pm | 4 +++- 3 files changed, 30 insertions(+), 1 deletion(-) 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; } -- 2.39.5