From 948470f8c8f3a8329dcdf71fb87956ebd3245c49 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Sat, 5 Nov 2022 06:31:38 -0700 Subject: [PATCH] fix c161, b1424, 1425 This simplifies code which gives priority to -wn over -pvt when both might apply --- CHANGES.md | 9 ++--- dev-bin/run_convergence_tests.pl.data | 58 +++++++++++++++++++++++++++ lib/Perl/Tidy/Formatter.pm | 18 ++++----- 3 files changed, 69 insertions(+), 16 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 22b28f85..a26f46d5 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -70,8 +70,8 @@ Also, previously a word following a '->' was given the color of a bareword, black by default, but now it is given the color of an identifier. - - Fixed incorrect formatting of any function named 'err'. This was - due to some old code when use feature 'err' was valid. + - Fixed incorrect indentation of any function named 'err'. This was + due to some old code from when "use feature 'err'" was valid. # OLD: my ($curr) = current(); @@ -82,8 +82,7 @@ err(@_); - Added parameter --delete-repeated-commas (-drc) to delete repeated - commas. This is off by default. I added this option after discovering - an unwanted repeated comma in the perltidy source. For example, given: + commas. This is off by default. For example, given: ignoreSpec( $file, "file",, \%spec, \%Rspec ); @@ -113,7 +112,7 @@ This will change some existing formatting. - The following new parameters are available for manipulating - trailing commas. They are described in the manual. + trailing commas of lists. They are described in the manual. --want-trailing-commas=s, -wtc=s --add-trailing-commas, -atc diff --git a/dev-bin/run_convergence_tests.pl.data b/dev-bin/run_convergence_tests.pl.data index 3ff68864..253ea427 100644 --- a/dev-bin/run_convergence_tests.pl.data +++ b/dev-bin/run_convergence_tests.pl.data @@ -10873,6 +10873,64 @@ L2hos --paren-vertical-tightness=1 --weld-nested-containers +==> b1424.in <== +$registry->add_type_constraint( Moose::Meta::TypeConstraint::Parameterizable + ->new( $a = 1; + $b = 1; + + ) ); + +$registry->add_type_constraint( + Moose::Meta::TypeConstraint::Parameterizable + ->new( $a = 1; + $b = 1; + + ) ); + + +==> b1424.par <== +--extended-line-up-parentheses +--indent-columns=8 +--keep-old-breakpoints-after='q >= - w ; <> ** & ? !=' +--stack-closing-paren +--vertical-tightness=1 +--weld-nested-containers + +==> b1425.in <== +my$sem=sub +{ + my$code=shift; + } + ->(sub + { + IPC::Semaphore->new(IPC_PRIVATE,$nsem, + S_IRWXU|S_IRWXG|S_IRWXO|IPC_CREAT); + } ); + +my$sem=sub +{ + my$code=shift; + } + ->( + sub + { + IPC::Semaphore->new(IPC_PRIVATE,$nsem, + S_IRWXU|S_IRWXG|S_IRWXO|IPC_CREAT); + } ); + + +==> b1425.par <== +--noadd-whitespace +--delete-old-whitespace +--extended-line-up-parentheses +--ignore-old-breakpoints +--maximum-line-length=51 +--opening-anonymous-sub-brace-on-new-line +--paren-vertical-tightness-closing=2 +--paren-vertical-tightness=1 +--variable-maximum-line-length +--weld-nested-containers + ==> b146.in <== # State 1 diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index b9b420d9..e8756acb 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -9994,19 +9994,16 @@ sub weld_nested_containers { } next if ($do_not_weld_rule); - # Turn off vertical tightness completely at possible one-line welds. - # Fixes b1402. This also fixes issues b1338, b1339, b1340, b1341, - # b1342, b1343, but both fixes are needed in general for good - # protection against instability. The line difference of '2' - # worked for b1402, but needs to be '3' to include b1419 because - # it has -vtc>0 which can add more uncertainty. - # And for case b1421 it had to be increased to '4'. + # Turn off vertical tightness at possible one-line welds. Fixes + # b1402,b1419,b1421,b1424,b1425. This also fixes issues b1338, b1339, + # b1340, b1341, b1342, b1343, but both fixes are needed in general for + # good protection against instability. Issue c161 is the latest and + # simplest check, using $iline_ic==$iline_io as the test. if ( %opening_vertical_tightness + && $iline_ic == $iline_io && $opening_vertical_tightness{$token_oo} ) { - if ( $iline_oc - $iline_oo <= 4 ) { - $rmax_vertical_tightness->{$outer_seqno} = 0; - } + $rmax_vertical_tightness->{$outer_seqno} = 0; } my $is_multiline_weld = @@ -12112,7 +12109,6 @@ sub xlp_collapsed_lengths { && $seqno_end == $rLL->[$Kc_test]->[_TYPE_SEQUENCE_] && $rLL->[$Kc_test]->[_LINE_INDEX_] == $iline + 1 ) { - my $Kc_test = $rLL->[$K_terminal]->[_KNEXT_SEQ_ITEM_]; my $line_of_tokens_next = $rlines->[ $iline + 1 ]; my $rtype_count = $rtype_count_by_seqno->{$seqno_end}; my $comma_count = -- 2.39.5