]> git.donarmstrong.com Git - perltidy.git/commitdiff
fix b1448
authorSteve Hancock <perltidy@users.sourceforge.net>
Thu, 2 Feb 2023 18:41:00 +0000 (10:41 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Thu, 2 Feb 2023 18:41:00 +0000 (10:41 -0800)
dev-bin/run_convergence_tests.pl.data
dev-bin/run_convergence_tests.pl.expect
lib/Perl/Tidy/Formatter.pm

index 8157e373ca01b24dd5d5e05ee815a745e7d9cfa8..4cf3b29b27e4ccb2513fc7c2b2ea1627263585e4 100644 (file)
@@ -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
 
index 8c2df7421cafedeaa8258eb3310dc9045953e290..74d83d00024cc03fc7feb891c24dad0f7c1ca35b 100644 (file)
@@ -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
 
index 0aa02702138cb95235791859e2dcf7697740ae32..e15b8da3dc66bf0f097559f08e0e534022ca7c83 100644 (file)
@@ -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;