]> git.donarmstrong.com Git - perltidy.git/commitdiff
fix -qwaf issue with backslash before closing paren, c414
authorSteve Hancock <perltidy@users.sourceforge.net>
Wed, 16 Oct 2024 00:21:15 +0000 (17:21 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Wed, 16 Oct 2024 00:21:15 +0000 (17:21 -0700)
lib/Perl/Tidy/Formatter.pm
t/snippets/expect/qwaf.def
t/snippets/expect/qwaf.qwaf
t/snippets/qwaf.in
t/snippets30.t

index b621d2582574e6dbd786f886e01be3e4b0f9bfe3..93cd6d5c48a9edc107bc47b6f7757fb2d0aff67d 100644 (file)
@@ -7061,6 +7061,23 @@ EOM
             return;
         }
 
+        # c414: do not join a '\' and a closing ')' for example like here:
+        #   my @clock_chars = qw( | / - \ | / - \ );
+        if (
+               @words
+            && $closing
+            && substr( $words[-1], -1, 1 ) eq '\\'
+            && (   $tightness{')'} == 2
+                || $tightness{')'} == 1 && @words == 1 )
+          )
+        {
+            # fix by including a space after the \
+            $words[-1] .= SPACE;
+
+            # and for symmetry, before the first word if the '(' is on this line
+            if ($opening) { $words[0] = SPACE . $words[0] }
+        }
+
         #---------------------------------------------------------------------
         # This is the point of no return if the transformation has not started
         #---------------------------------------------------------------------
index 1e3a0fade1b78a2e69adf614097101a5b8a18828..8229e0eedf1fc98728e78a7925cba3be5bceb243 100644 (file)
@@ -25,3 +25,4 @@ use Digest::MD5 qw( md5_hex );
   SlateBlue1
 );
 
+@list = qw( \ );
index 0a781fc43b226c5597e9136d525b4af44891851d..1413a70dc4ecfd5e6c92f714d4577426ee2692d0 100644 (file)
@@ -19,3 +19,4 @@ use Digest::MD5 qw(md5_hex);
     SlateBlue1
 );
 
+@list = qw( \ );
index 63ab248031b5714d0832f28f3e4c11ab07d20b0f..e9663e96504cb672628e8690b1980bcaf3fc6d63 100644 (file)
@@ -25,3 +25,4 @@ use Digest::MD5 qw( md5_hex );
         SlateBlue1
     );
 
+@list = qw( \ );
index dcc3050e30368872bc332d48372a7c52d013fe7e..3170b9726c4b2f388d192ce57323af2da886e7e1 100644 (file)
@@ -179,6 +179,7 @@ use Digest::MD5 qw( md5_hex );
         SlateBlue1
     );
 
+@list = qw( \ );
 ----------
     };
 
@@ -453,6 +454,7 @@ use Digest::MD5 qw( md5_hex );
   SlateBlue1
 );
 
+@list = qw( \ );
 #17...........
         },
 
@@ -481,6 +483,7 @@ use Digest::MD5 qw(md5_hex);
     SlateBlue1
 );
 
+@list = qw( \ );
 #18...........
         },
     };