From: Steve Hancock Date: Thu, 2 Feb 2023 18:41:00 +0000 (-0800) Subject: fix b1448 X-Git-Tag: 20230309~46 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=2ac6d5c940ef476ef494c4be81d737da84be8311;p=perltidy.git fix b1448 --- diff --git a/dev-bin/run_convergence_tests.pl.data b/dev-bin/run_convergence_tests.pl.data index 8157e373..4cf3b29b 100644 --- a/dev-bin/run_convergence_tests.pl.data +++ b/dev-bin/run_convergence_tests.pl.data @@ -11393,6 +11393,38 @@ $last = after ( --vertical-tightness=2 --weld-nested-containers +==> b1448.in <== + $save_check = + $menu_frame->Checkbutton( + -variable => \$root->{'modified'}, + ( $os ne 'win' ? ( -selectcolor => "red" ) : () ), + -highlightthickness => 0, + -padx => 0, + -pady => 0, + + #-font => "times 5", + ); + + $save_check = + $menu_frame->Checkbutton( + -variable => \$root->{'modified'}, + ( + $os ne 'win' ? ( -selectcolor => "red" ) : () + ), + -highlightthickness => 0, + -padx => 0, + -pady => 0, + + #-font => "times 5", + ); + + +==> b1448.par <== +--continuation-indentation=9 +--extended-line-up-parentheses +--indent-columns=7 +--paren-vertical-tightness-closing=1 + ==> b146.in <== # State 1 diff --git a/dev-bin/run_convergence_tests.pl.expect b/dev-bin/run_convergence_tests.pl.expect index 8c2df742..74d83d00 100644 --- a/dev-bin/run_convergence_tests.pl.expect +++ b/dev-bin/run_convergence_tests.pl.expect @@ -7231,34 +7231,30 @@ my %MyTokens= ( ==> b1408 <== $registry->add_type_constraint( - Moose::Meta::TypeConstraint::Parameterizable->new( - parent => - Moose::Util::TypeConstraints::find_type_constraint( - 'Ref' ), - constraint_generator => sub { - - return sub { - foreach my $x ( @$_ ) { - ( $check->( $x ) ) - || return; - } - } - }, ) ); + Moose::Meta::TypeConstraint::Parameterizable->new( + parent => + Moose::Util::TypeConstraints::find_type_constraint( 'Ref' ), + constraint_generator => sub { + + return sub { + foreach my $x ( @$_ ) { + ( $check->( $x ) ) || return; + } + } + }, ) ); $registry->add_type_constraint( - Moose::Meta::TypeConstraint::Parameterizable->new( - parent => - Moose::Util::TypeConstraints::find_type_constraint( - 'Ref' ), - constraint_generator => sub { - - return sub { - foreach my $x ( @$_ ) { - ( $check->( $x ) ) - || return; - } - } - }, ) ); + Moose::Meta::TypeConstraint::Parameterizable->new( + parent => + Moose::Util::TypeConstraints::find_type_constraint( 'Ref' ), + constraint_generator => sub { + + return sub { + foreach my $x ( @$_ ) { + ( $check->( $x ) ) || return; + } + } + }, ) ); ==> b1409 <== @@ -7730,6 +7726,30 @@ $last = after ( 2981014)] ) )); +==> b1448 <== + $save_check = + $menu_frame->Checkbutton( + -variable => \$root->{'modified'}, + ( $os ne 'win' ? ( -selectcolor => "red" ) : () ), + -highlightthickness => 0, + -padx => 0, + -pady => 0, + + #-font => "times 5", + ); + + $save_check = + $menu_frame->Checkbutton( + -variable => \$root->{'modified'}, + ( $os ne 'win' ? ( -selectcolor => "red" ) : () ), + -highlightthickness => 0, + -padx => 0, + -pady => 0, + + #-font => "times 5", + ); + + ==> b146 <== # State 1 diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 0aa02702..e15b8da3 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -12753,7 +12753,33 @@ sub is_fragile_block_type { ) { - # $len => $leng to fix b1302 b1306 b1317 b1321 + # An additional check: if line ends in ), and the ) has vtc then + # skip this estimate. Otherwise, vtc can give oscillating results. + # Fixes b1448. For example, this could be unstable: + + # ( $os ne 'win' ? ( -selectcolor => "red" ) : () ), + # | |^--K_comma + # | ^-- K_prev + # ^--- KK + + # An alternative, possibly better strategy would be to try to turn + # off -vtc locally, but it turns out to be difficult to locate the + # appropriate closing token when it is not on the same line as its + # opening token. + + my $K_prev = $self->K_previous_nonblank($K_comma); + if ( defined($K_prev) + && $K_prev >= $KK + && $rLL->[$K_prev]->[_TYPE_SEQUENCE_] ) + { + my $token = $rLL->[$K_prev]->[_TOKEN_]; + my $type = $rLL->[$K_prev]->[_TYPE_]; + if ( $closing_vertical_tightness{$token} && $type ne 'R' ) { + ## type 'R' does not normally get broken, so ignore + ## skip length calculation + return 0; + } + } my $starting_len = $KK >= 0 ? $rLL->[ $KK - 1 ]->[_CUMULATIVE_LENGTH_] : 0; $length = $rLL->[$K_comma]->[_CUMULATIVE_LENGTH_] - $starting_len;