]> git.donarmstrong.com Git - perltidy.git/commitdiff
fix stability issue b1492
authorSteve Hancock <perltidy@users.sourceforge.net>
Wed, 23 Oct 2024 13:58:27 +0000 (06:58 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Wed, 23 Oct 2024 13:58:27 +0000 (06:58 -0700)
dev-bin/run_convergence_tests.pl.data
dev-bin/run_convergence_tests.pl.expect
lib/Perl/Tidy/Formatter.pm

index 2a6dc5afe44266dbc2a6a5b210a9d2f82d22a901..f4f168294154cce4cf322a2f73f564bf7e2d0619 100644 (file)
@@ -12341,6 +12341,55 @@ $e_str->bind ( '<return>' => sub {$e_hnr->tabfocus if $e_hnr->can ( 'tabfocus' )
 --add-trailing-commas
 --want-trailing-commas=1
 
+==> b1492.in <==
+        $col->configure ( -command =>
+              sub { $t->configure ( -background => $color ); } );
+
+        $col->configure(
+            -command => sub { $t->configure(-background => $color); },
+        );
+
+==> b1492.par <==
+--maximum-line-length=58
+--variable-maximum-line-length
+--space-function-paren
+--paren-tightness=2
+--add-trailing-commas
+--want-trailing-commas='h'
+--delete-trailing-commas
+
+==> b1493.in <==
+        $w->bind('<Page_Down>' =>
+              sub { $t1->yview(scroll => 1, 'pages'); },);
+
+        $w->bind(
+            '<Page_Down>' => sub { $t1->yview(scroll => 1, 'pages'); }
+        );
+
+==> b1493.par <==
+--maximum-line-length=58
+--variable-maximum-line-length
+--paren-tightness=2
+--add-trailing-commas
+--want-trailing-commas='h'
+--delete-trailing-commas
+
+==> b1494.in <==
+        $b4->bind('<1>' =>
+              sub { cset('D', 'HilightColorFore', "\$color"); },);
+
+        $b4->bind(
+            '<1>' => sub { cset('D', 'HilightColorFore', "\$color"); }
+        );
+
+==> b1494.par <==
+--maximum-line-length=58
+--variable-maximum-line-length
+--paren-tightness=2
+--add-trailing-commas
+--want-trailing-commas='h'
+--delete-trailing-commas
+
 ==> b156.in <==
 # State 1
 {
index f744fb05f0d0da40c0a09b432b5bca25b43b3a6c..359b58c78c3aa1c9361d9c13c9ad626d4bb288e3 100644 (file)
@@ -8351,6 +8351,33 @@ $e_str->bind (
     Stack )
        ; # inherit from Stack
 
+==> b1492 <==
+        $col->configure (
+            -command => sub { $t->configure (-background => $color); }
+        );
+
+        $col->configure (
+            -command => sub { $t->configure (-background => $color); }
+        );
+
+==> b1493 <==
+        $w->bind(
+            '<Page_Down>' => sub { $t1->yview(scroll => 1, 'pages'); }
+        );
+
+        $w->bind(
+            '<Page_Down>' => sub { $t1->yview(scroll => 1, 'pages'); }
+        );
+
+==> b1494 <==
+        $b4->bind(
+            '<1>' => sub { cset('D', 'HilightColorFore', "\$color"); }
+        );
+
+        $b4->bind(
+            '<1>' => sub { cset('D', 'HilightColorFore', "\$color"); }
+        );
+
 ==> b156 <==
 # State 1
 {
index 29551f7874dc0d4f8cc4beba295138ed856341e0..aa4e2c1a4ef99253622d8efb9532d80116e7e74b 100644 (file)
@@ -14689,6 +14689,8 @@ sub match_trailing_comma_rule {
         $fat_comma_count = $rtype_count->{'=>'};
     }
 
+    my $follows_isolated_closing_token;
+
     #----------------------------------------------------------------
     # If no existing commas, see if we have an inner nested container
     #----------------------------------------------------------------
@@ -14719,6 +14721,16 @@ sub match_trailing_comma_rule {
             return;
         }
 
+        # Does this trailing comma follow an isolated closing token?
+        if ($is_nesting_right) {
+            my $ix_pp = $rLL_new->[$Kpp]->[_LINE_INDEX_];
+            my $Kpp_m = $self->K_previous_nonblank( $Kpp, $rLL_new );
+            if ($Kpp_m) {
+                my $ix_pp_m = $rLL_new->[$Kpp_m]->[_LINE_INDEX_];
+                $follows_isolated_closing_token = $ix_pp > $ix_pp_m;
+            }
+        }
+
         #--------------------------------
         # If no comma and no fat comma...
         #--------------------------------
@@ -14809,8 +14821,20 @@ sub match_trailing_comma_rule {
 
               # or has a fat comma not in parens or in parens over several lines
               # (b1489, b1490)
-              || ( $fat_comma_count
-                && ( !$is_paren_list || $iline_c - $iline_o > 1 ) )
+              || (
+                $fat_comma_count
+                ## stability fix for b1492 b1493 b1494: a single fat comma in
+                ## parens must follow an isolated closing token
+                ##&& ( !$is_paren_list || $iline_c - $iline_o > 1 ) )
+                && (
+                    !$is_paren_list
+                    || (
+                        ( $iline_c - $iline_o > 1 )
+                        && (   $follows_isolated_closing_token
+                            || $fat_comma_count > 1 )
+                    )
+                )
+              )
 
               # or contains an inner multiline structure
               || $has_inner_multiline_structure