]> git.donarmstrong.com Git - perltidy.git/commitdiff
fix issue b1213
authorSteve Hancock <perltidy@users.sourceforge.net>
Wed, 6 Oct 2021 19:04:20 +0000 (12:04 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Wed, 6 Oct 2021 19:04:20 +0000 (12:04 -0700)
dev-bin/run_convergence_tests.pl.data
lib/Perl/Tidy/Formatter.pm

index 983aa5dc5ba7b9cd534948869be79a14ef2f4091..8722f6df15c620b0408b67009bc1d63b2c7b8b42 100644 (file)
@@ -7480,6 +7480,25 @@ $bc[
 --variable-maximum-line-length
 --weld-nested-containers
 
+==> b1213.in <==
+# S1
+     @NNVN_w1 = ( Perl,
+                  Practical,
+                  Precocious
+     );
+# S2
+     @NNVN_w1 =
+             ( Perl, Practical,
+               Precocious
+             );
+
+==> b1213.par <==
+--continuation-indentation=8
+--ignore-old-breakpoints
+--indent-columns=5
+--line-up-parentheses
+--maximum-line-length=35
+
 ==> b1214.in <==
 # S1
             eval {
index 6b6f1bd02f72a5cd1007e68e248c3eb4db0ad226..8a4c83c837d532a04523c858c95b86326a258376 100644 (file)
@@ -3873,46 +3873,28 @@ EOM
                 $bond_str = NO_BREAK;
             }
 
-            # in older version of perl, use strict can cause problems with
-            # breaks before bare words following opening parens.  For example,
-            # this will fail under older versions if a break is made between
-            # '(' and 'MAIL': use strict; open( MAIL, "a long filename or
-            # command"); close MAIL;
+            # OLD COMMENT: In older version of perl, use strict can cause
+            # problems with breaks before bare words following opening parens.
+            # For example, this will fail under older versions if a break is
+            # made between '(' and 'MAIL':
+
+            # use strict; open( MAIL, "a long filename or command"); close MAIL;
+
+            # NEW COMMENT: Third fix for b1213:
+            # This option does not seem to be needed any longer, and it can
+            # cause instabilities.  It can be turned off, but to minimize
+            # changes to existing formatting it is retained only in the case
+            # where the previous token was 'open' and there was no line break.
+            # Even this could eventually be removed if it causes instability.
             if ( $type eq '{' ) {
 
-                if ( $token eq '(' && $next_nonblank_type eq 'w' ) {
-
-                    # but it's fine to break if the word is followed by a '=>'
-                    # or if it is obviously a sub call
-                    my $i_next_next_nonblank = $i_next_nonblank + 1;
-                    my $next_next_type = $types_to_go[$i_next_next_nonblank];
-                    if (   $next_next_type eq 'b'
-                        && $i_next_nonblank < $max_index_to_go )
-                    {
-                        $i_next_next_nonblank++;
-                        $next_next_type = $types_to_go[$i_next_next_nonblank];
-                    }
-
-                    # We'll check for an old breakpoint and keep a leading
-                    # bareword if it was that way in the input file.
-                    # Presumably it was ok that way.  For example, the
-                    # following would remain unchanged:
-                    #
-                    # @months = (
-                    #   January,   February, March,    April,
-                    #   May,       June,     July,     August,
-                    #   September, October,  November, December,
-                    # );
-                    #
-                    # This should be sufficient:
-                    if (
-                        !$old_breakpoint_to_go[$i]
-                        && (   $next_next_type eq ','
-                            || $next_next_type eq '}' )
-                      )
-                    {
-                        $bond_str = NO_BREAK;
-                    }
+                if (   $token eq '('
+                    && $next_nonblank_type eq 'w'
+                    && $last_nonblank_type eq 'k'
+                    && $last_nonblank_token eq 'open'
+                    && !$old_breakpoint_to_go[$i] )
+                {
+                    $bond_str = NO_BREAK;
                 }
             }