]> git.donarmstrong.com Git - perltidy.git/commitdiff
make space controls work better around here targets
authorSteve Hancock <perltidy@users.sourceforge.net>
Wed, 6 Nov 2024 22:42:42 +0000 (14:42 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Wed, 6 Nov 2024 22:42:42 +0000 (14:42 -0800)
CHANGES.md
dev-bin/run_convergence_tests.pl.expect
lib/Perl/Tidy/Formatter.pm

index d32e7cf0295e98dcff38b90155006b4f7174dff2..f0ac1b67fe0f731a1977871a4f52ea114d872ba0 100644 (file)
@@ -2,6 +2,15 @@
 
 ## 2024 09 03.06
 
+    - Space around here doc delimiters follow spacing controls better. For
+    example, a space is now added before the closing paren here:
+
+       OLD: (without the here doc):
+       push( @script, <<'EOT');
+
+       NEW:
+       push( @script, <<'EOT' );
+
     - Added parameter --break-at-trailing-comma-types=s, or -btct=s, where
     s is a string which selects trailing commas.  For example, -btct='f(b'
     places a line break after all bare trailing commas in function calls.
index 69a733233ddbf3779521e9dccfe81b680b1e3d0b..940c2a961c48ca084cbb8cb450854f3f7556690c 100644 (file)
@@ -9617,13 +9617,13 @@ my (
 
 ==> b523 <==
                 foreach my $name (@$names)
-                  { unless ($callcopy) { $ret .= << "EOC"}
+                  { unless ($callcopy) { $ret .= << "EOC" }
 XX
 EOC
                   }
 
                 foreach my $name (@$names)
-                  { unless ($callcopy) { $ret .= << "EOC"}
+                  { unless ($callcopy) { $ret .= << "EOC" }
 XX
 EOC
                   }
index a3b41553277b1c5c778b6ff438e9baf017782a9d..51349ad7e5a593066a7a37718ca04c69c83a6b78 100644 (file)
@@ -4581,16 +4581,11 @@ sub set_whitespace_flags {
         }
 
         # always preserve whatever space was used after a possible
-        # filehandle (except _) or here doc operator
-        if (
-            (
-                ( $last_type eq 'Z' && $last_token ne '_' )
-                || $last_type eq 'h'
-            )
-            && $type ne '#' # no longer required due to early exit for '#' above
-          )
-        {
+        # filehandle (except _)
+        if ( $last_type eq 'Z' && $last_token ne '_' ) {
+
             # no space for '$ {' even if '$' is marked as type 'Z', issue c221
+            # note: redundant check on type 'h' here removed for c419 part 2b
             if ( $last_type eq 'Z' && $last_token eq '$' && $token eq '{' ) {
                 $ws = WS_NO;
             }
@@ -5123,8 +5118,8 @@ EOM
           # It can cause a syntax error if oops is a sub
           || $typel eq 'w' && ( $tokenr eq '-' || $typer eq 'Q' )
 
-          # perl is very fussy about spaces before <<
-          || $tokenr_leading_ch2 eq '<<'
+          # perl is very fussy about spaces before <<; c419 part 1
+          || $tokenr_leading_ch2 eq '<<' && $typel ne '{' && $typel ne ','
 
           # avoid combining tokens to create new meanings. Example:
           #     $a+ +$b must not become $a++$b
@@ -5169,8 +5164,9 @@ EOM
             )
           )    ## end $tokenr_is_open_paren
 
-          # retain any space after here doc operator ( hereerr.t)
-          || $typel eq 'h'
+          # retain any space after here doc operator ( see hereerr.t)
+          # c419, part 2a: unless followed by '}' or ','. See also part 2b.
+          || $typel eq 'h' && $typer ne '}' && $typer ne ','
 
           # Be careful with a space around ++ and --, to avoid ambiguity as to
           # which token it applies
@@ -32310,7 +32306,6 @@ EOM
     } ## end sub break_lists_decreasing_depth
 } ## end closure break_lists
 
-
 my %is_kwiZ;
 my %is_key_type;