]> git.donarmstrong.com Git - perltidy.git/commitdiff
fix b1446
authorSteve Hancock <perltidy@users.sourceforge.net>
Mon, 30 Jan 2023 17:52:48 +0000 (09:52 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Mon, 30 Jan 2023 17:52:48 +0000 (09:52 -0800)
dev-bin/run_convergence_tests.pl.data
dev-bin/run_convergence_tests.pl.expect
lib/Perl/Tidy/Formatter.pm

index bc9f7f3507fe3251ede2b7ac92b368aec077aa34..8157e373ca01b24dd5d5e05ee815a745e7d9cfa8 100644 (file)
@@ -11338,6 +11338,40 @@ $last = after (
 --maximum-line-length=20
 --opening-hash-brace-right
 
+==> b1446.in <==
+     serverprint($d,
+                 &X::newxCreateGlyphCursorReq(
+                                             $cursor=&next_resource_id,
+                                             $c,# sourcefont
+                                             $c,# maskfont
+                                             $ch,# sourcechar
+                                             $ch+1,# maskchar
+                                             $fr,$fg,$fb,
+                                             $br,$bg,$bb
+                 )
+     );
+
+     serverprint(
+         $d,
+         &X::newxCreateGlyphCursorReq($cursor=&next_resource_id,
+                                      $c,# sourcefont
+                                      $c,# maskfont
+                                      $ch,# sourcechar
+                                      $ch+1,# maskchar
+                                      $fr,$fg,$fb,
+                                      $br,$bg,$bb
+         )
+     );
+
+==> b1446.par <==
+--noadd-whitespace
+--delete-old-whitespace
+--extended-line-up-parentheses
+--indent-columns=5
+--maximum-line-length=56
+--variable-maximum-line-length
+--vertical-tightness=2
+
 ==> b1447.in <==
     ok(defined($seqio=
                   $gb->get_Stream_by_batch([qw(J00522 AF303112
index 289ca7d2ef8f7a006778531d6669bf2bfabed92e..8c2df7421cafedeaa8258eb3310dc9045953e290 100644 (file)
@@ -6122,18 +6122,18 @@ $obj = {
 subtest '->save' => sub {
     plan tests => 1;
     my $layout
-    =C4::Patroncards::Layout->new ( layout_name => "new patron card",
-                                    layout_id   => '',               # The interface send an empty string
-                                    layout_xml  => 'some_xml'
+    =C4::Patroncards::Layout->new (layout_name => "new patron card",
+                                   layout_id   => '',                # The interface send an empty string
+                                   layout_xml  => 'some_xml'
     );
 };
 
 subtest '->save' => sub {
     plan tests => 1;
     my $layout
-    =C4::Patroncards::Layout->new ( layout_name => "new patron card",
-                                    layout_id   => '',               # The interface send an empty string
-                                    layout_xml  => 'some_xml'
+    =C4::Patroncards::Layout->new (layout_name => "new patron card",
+                                   layout_id   => '',                # The interface send an empty string
+                                   layout_xml  => 'some_xml'
     );
 };
 
@@ -7694,6 +7694,31 @@ $last = after (
                   die
 "Unrecognized $type number: $num\n";
 
+==> b1446 <==
+     serverprint(
+         $d,
+         &X::newxCreateGlyphCursorReq($cursor=&next_resource_id,
+                                      $c,# sourcefont
+                                      $c,# maskfont
+                                      $ch,# sourcechar
+                                      $ch+1,# maskchar
+                                      $fr,$fg,$fb,
+                                      $br,$bg,$bb
+         )
+     );
+
+     serverprint(
+         $d,
+         &X::newxCreateGlyphCursorReq($cursor=&next_resource_id,
+                                      $c,# sourcefont
+                                      $c,# maskfont
+                                      $ch,# sourcechar
+                                      $ch+1,# maskchar
+                                      $fr,$fg,$fb,
+                                      $br,$bg,$bb
+         )
+     );
+
 ==> b1447 <==
     ok(defined($seqio=
                   $gb->get_Stream_by_batch([qw(J00522 AF303112
index d3b54033a29a6aab48b1411d7fd8890b22d18ccd..ca8a4f0b18577a44f783be3e37c78eb977e6a012 100644 (file)
@@ -12721,6 +12721,46 @@ sub is_fragile_block_type {
         return;
     }
 
+    sub cumulative_length_to_comma {
+        my ( $self, $KK, $K_comma, $K_closing ) = @_;
+
+        # Given:
+        #  $KK        = index of starting token, or blank before start
+        #  $K_comma   = index of line-ending comma
+        #  $K_closing = index of the container closing token
+
+        # Return:
+        #  $length = cumulative length of the term
+
+        my $rLL = $self->[_rLL_];
+        if ( $rLL->[$KK]->[_TYPE_] eq 'b' ) { $KK++ }
+        my $length = 0;
+        if (
+               $KK < $K_comma
+            && $rLL->[$K_comma]->[_TYPE_] eq ','    # should be true
+
+            # Ignore if terminal comma, causes instability (b1297,
+            # b1330)
+            && (
+                $K_closing - $K_comma > 2
+                || (   $K_closing - $K_comma == 2
+                    && $rLL->[ $K_comma + 1 ]->[_TYPE_] ne 'b' )
+            )
+
+            # The comma should be in this container
+            && ( $rLL->[$K_comma]->[_LEVEL_] - 1 ==
+                $rLL->[$K_closing]->[_LEVEL_] )
+          )
+        {
+
+            # $len => $leng to fix b1302 b1306 b1317 b1321
+            my $starting_len =
+              $KK >= 0 ? $rLL->[ $KK - 1 ]->[_CUMULATIVE_LENGTH_] : 0;
+            $length = $rLL->[$K_comma]->[_CUMULATIVE_LENGTH_] - $starting_len;
+        }
+        return $length;
+    } ## end sub cumulative_length_to_comma
+
     sub xlp_collapsed_lengths {
 
         my $self = shift;
@@ -12975,31 +13015,21 @@ sub is_fragile_block_type {
                     #--------------------------
                     # END patch for issue b1408
                     #--------------------------
+                    if ( $rLL->[$K_terminal]->[_TYPE_] eq ',' ) {
 
-                    if (
-                        $rLL->[$K_terminal]->[_TYPE_] eq ','
-
-                        # Ignore if terminal comma, causes instability (b1297,
-                        # b1330)
-                        && (
-                            $K_c - $K_terminal > 2
-                            || (   $K_c - $K_terminal == 2
-                                && $rLL->[ $K_terminal + 1 ]->[_TYPE_] ne 'b' )
-                        )
-                      )
-                    {
-
-                        # $len => my $leng to fix b1302 b1306 b1317 b1321
-                        my $leng = $rLL->[$K_terminal]->[_CUMULATIVE_LENGTH_] -
-                          $rLL->[ $K_first - 1 ]->[_CUMULATIVE_LENGTH_];
+                        my $length =
+                          $self->cumulative_length_to_comma( $K_first,
+                            $K_terminal, $K_c );
 
                         # Fix for b1331: at a broken => item, include the
                         # length of the previous half of the item plus one for
                         # the missing space
                         if ( $last_nonblank_type eq '=>' ) {
-                            $leng += $len + 1;
+                            $length += $len + 1;
+                        }
+                        if ( $length > $max_prong_len ) {
+                            $max_prong_len = $length;
                         }
-                        if ( $leng > $max_prong_len ) { $max_prong_len = $leng }
                     }
                 }
             }
@@ -13140,6 +13170,27 @@ sub is_fragile_block_type {
 
                     my $K_c = $K_closing_container->{$seqno};
 
+                    # Add length of any terminal list item if interrupted
+                    # so that the result is the same as if the term is
+                    # in the next line (b1446).
+
+                    if (
+                           $interrupted_list_rule
+                        && $KK < $K_terminal
+
+                        # The line should end in a comma
+                        # NOTE: this currently assumes break after comma.
+                        # As long as the other call to cumulative_length..
+                        # makes the same assumption we should remain stable.
+                        && $rLL->[$K_terminal]->[_TYPE_] eq ','
+
+                      )
+                    {
+                        $max_prong_len =
+                          $self->cumulative_length_to_comma( $KK + 1,
+                            $K_terminal, $K_c );
+                    }
+
                     push @stack, [
 
                         $max_prong_len,
@@ -13150,6 +13201,7 @@ sub is_fragile_block_type {
                         $K_c,
                         $interrupted_list_rule
                     ];
+
                 }
 
                 #--------------------