From: Steve Hancock Date: Sun, 16 Oct 2022 00:31:27 +0000 (-0700) Subject: fix issue b1384 X-Git-Tag: 20221112~43 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=cd785fce9518a4bd0709fa3bf966f199cc799763;p=perltidy.git fix issue b1384 --- diff --git a/dev-bin/run_convergence_tests.pl.data b/dev-bin/run_convergence_tests.pl.data index 5a19b930..17a8504b 100644 --- a/dev-bin/run_convergence_tests.pl.data +++ b/dev-bin/run_convergence_tests.pl.data @@ -10173,7 +10173,8 @@ $font_size ==> b1376.par <== ---add-trailing-commas='b' +--add-trailing-commas +--want-trailing-commas='b' --extended-line-up-parentheses --indent-columns=6 --maximum-line-length=47 @@ -10245,6 +10246,33 @@ my $formatter = new HTML::FormatPS( --want-trailing-commas='b' --variable-maximum-line-length +==> b1384.in <== + eval{ + my@a=(foo=>'baz',bar=>'quux'); + validate(@a, + {foo=>{regex=>qr/^baz$/},bar=>{regex=>'uqqx'}}, + ); + }; + + eval{ + my@a=(foo=>'baz',bar=>'quux'); + validate(@a,{foo=>{regex=>qr/^baz$/},bar=>{regex=>'uqqx'}}); + }; + + +==> b1384.par <== +--add-trailing-commas +--noadd-whitespace +--continuation-indentation=6 +--delete-old-whitespace +--delete-trailing-commas +--extended-continuation-indentation +--ignore-old-breakpoints +--maximum-line-length=65 +--paren-vertical-tightness-closing=2 +--variable-maximum-line-length +--want-trailing-commas='m' + ==> b1385.in <== ( # optional glob diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 190297e7..4cb161cd 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -8127,12 +8127,10 @@ sub match_trailing_comma_rule { $rLL_new ); } - # Fix for b1379, b1380, b1381, b1382 part 1. Mark bare trailing commas for - # use by -vtc logic to avoid instability when -dtc and -atc are both + # Fix for b1379, b1380, b1381, b1382, b1384 part 1. Mark trailing commas + # for use by -vtc logic to avoid instability when -dtc and -atc are both # active. - if ( $match - && ( $trailing_comma_style eq 'b' || $trailing_comma_style eq 'h' ) ) - { + if ($match) { if ( $if_add && $rOpts_delete_trailing_commas || !$if_add && $rOpts_add_trailing_commas ) { @@ -27574,10 +27572,11 @@ sub set_vertical_tightness_flags { $cvt = 1; } - # Fix for b1379, b1380, b1381, b1382 part 2. - # Instablility with adding and deleting trailing bare commas. - # Reducing -cvt=2 to -cvt=1 fixes stability in b1379, b1380. - # Reducing -cvt>0 to -cvt=0 fixes stability in b1381, b1382. + # Fix for b1379, b1380, b1381, b1382, b1384 part 2, + # instablility with adding and deleting trailing commas: + # Reducing -cvt=2 to =1 fixes stability for -wtc=b in b1379,1380. + # Reducing -cvt>0 to =0 fixes stability for -wtc=b in b1381,1382. + # Reducing -cvt>0 to =0 fixes stability for -wtc=m in b1384 if ( $cvt && $self->[_ris_bare_trailing_comma_by_seqno_]->{$seqno} ) {