]> git.donarmstrong.com Git - perltidy.git/commitdiff
Avoid line breaks before a slash in certain cases
authorSteve Hancock <perltidy@users.sourceforge.net>
Mon, 12 Jul 2021 01:31:10 +0000 (18:31 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Mon, 12 Jul 2021 01:31:10 +0000 (18:31 -0700)
lib/Perl/Tidy/Formatter.pm
local-docs/BugLog.pod

index 4e9958497ab57d9ebcade275e7b6ec5411caab77..a24492de3497433a3ec81481dac9a015e3d51b71 100644 (file)
@@ -3728,8 +3728,9 @@ EOM
                     )
 
                     # or we might be followed by the start of a quote,
-                    # fixes c039.
-                    || substr( $next_nonblank_token, 0, 1 ) eq '/'
+                    # and this is not an existing breakpoint; fixes c039.
+                    || !$old_breakpoint_to_go[$i]
+                    && substr( $next_nonblank_token, 0, 1 ) eq '/'
 
                   )
                 {
@@ -3760,7 +3761,8 @@ EOM
             # Fix for c039
             elsif ( $type eq 'w' ) {
                 $bond_str = NO_BREAK
-                  if ( substr( $next_nonblank_token, 0, 1 ) eq '/' );
+                  if ( !$old_breakpoint_to_go[$i]
+                    && substr( $next_nonblank_token, 0, 1 ) eq '/' );
             }
 
             my $bond_str_2 = $bond_str;
@@ -5914,7 +5916,8 @@ sub respace_tokens {
                                 $is_block_without_semicolon{
                                     $last_nonblank_block_type}
                                 || $last_nonblank_block_type =~ /$SUB_PATTERN/
-                                || $last_nonblank_block_type =~ /^\w+:$/ )
+                                || $last_nonblank_block_type =~ /^\w+:$/
+                            )
                         )
                         || $last_nonblank_type eq ';'
                     )
@@ -21410,9 +21413,12 @@ sub make_paren_name {
         # an isolated brace
         #############################################################
         my $is_isolated_block_brace = $block_type_to_go[$ibeg]
-          && ( $i_terminal == $ibeg
+          && (
+            $i_terminal == $ibeg
             || $is_if_elsif_else_unless_while_until_for_foreach{
-                $block_type_to_go[$ibeg] } );
+                $block_type_to_go[$ibeg]
+            }
+          );
 
         # only do this for a ':; which is aligned with its leading '?'
         my $is_unaligned_colon = $types_to_go[$ibeg] eq ':' && !$is_leading;
index ca984434636a9ef9d9ed0d1fc933d0e225cc0b71..8bc5b17d16e4112c1e860747157c3c1c6f0c7a28 100644 (file)
@@ -2,6 +2,13 @@
 
 =over 4
 
+=item B<Avoid line breaks before a slash in certain cases>
+
+This is a modification to the previous update for case c039 which prevents a line break before a '/' character which follows a bareword or possible indirect object.  This rule
+will be only be used to prevent creating new line breaks. Existing line breaks can remain.
+
+11 Jul 2021
+
 =item B<Fix error parsing sub attributes with side comment>
 
 Testing with side comments produced an error in the following snippet: