]> git.donarmstrong.com Git - perltidy.git/commitdiff
fix c424, lost space with -qwaf -naws and '\ )'
authorSteve Hancock <perltidy@users.sourceforge.net>
Sat, 23 Nov 2024 15:31:32 +0000 (07:31 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sat, 23 Nov 2024 15:31:32 +0000 (07:31 -0800)
lib/Perl/Tidy/Formatter.pm
t/snippets/c424.in [new file with mode: 0644]
t/snippets/c424.par [new file with mode: 0644]
t/snippets/expect/c424.c424 [new file with mode: 0644]
t/snippets/expect/c424.def [new file with mode: 0644]
t/snippets/packing_list.txt
t/snippets31.t

index 8482d196dd0a96e7c4cb6c330126a1f9f5e80234..85e588b1fa2a1d5c00cdcc7ab5d5b78c958c3e8b 100644 (file)
@@ -7452,21 +7452,26 @@ EOM
             return;
         }
 
-        # c414: do not join a '\' and a closing ')' for example like here:
+        # c414 and c424: do not join a '\' and a closing ')' like here:
         #   my @clock_chars = qw( | / - \ | / - \ );
         if (
                @words
             && $closing
             && substr( $words[-1], -1, 1 ) eq BACKSLASH
-            && (   $tightness{')'} == 2
-                || $tightness{')'} == 1 && @words == 1 )
+            && (
+                !$rOpts_add_whitespace
+                || (   $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] }
+            if ( $opening && $rOpts_add_whitespace ) {
+                $words[0] = SPACE . $words[0];
+            }
         }
 
         #---------------------------------------------------------------------
@@ -38520,6 +38525,12 @@ sub make_paren_name {
         # indentation of a line in the Formatter.
         #--------------------------------------------------------------
 
+        # Given:
+        #   ($ibeg, $iend) = index range of tokens on this line
+        #   $rindentation_list = ref to indentation of each line in this batch,
+        #                        to be updated by this sub
+        #   $level_jump = level change to $token $ibeg from previous token
+
         # It starts with the basic indentation which has been defined for the
         # leading token, and then takes into account any options that the user
         # has set regarding special indenting and outdenting.
diff --git a/t/snippets/c424.in b/t/snippets/c424.in
new file mode 100644 (file)
index 0000000..cf1c6c4
--- /dev/null
@@ -0,0 +1,2 @@
+my @chars = qw(   | / - \ | / - \    );
+my @chars = qw(| / - \ | / - \ );
diff --git a/t/snippets/c424.par b/t/snippets/c424.par
new file mode 100644 (file)
index 0000000..361ea4f
--- /dev/null
@@ -0,0 +1 @@
+-naws -qwaf
diff --git a/t/snippets/expect/c424.c424 b/t/snippets/expect/c424.c424
new file mode 100644 (file)
index 0000000..f92d92e
--- /dev/null
@@ -0,0 +1,2 @@
+my @chars = qw( | / - \ | / - \ );
+my @chars = qw(| / - \ | / - \ );
diff --git a/t/snippets/expect/c424.def b/t/snippets/expect/c424.def
new file mode 100644 (file)
index 0000000..cf1c6c4
--- /dev/null
@@ -0,0 +1,2 @@
+my @chars = qw(   | / - \ | / - \    );
+my @chars = qw(| / - \ | / - \ );
index 77f42a26c34400dcb22df6ab6733aa915c08ab1a..19d8c8fc87f125751b974e1f69aa7dcabb492a68 100644 (file)
 ../snippets30.t        git162.git162
 ../snippets30.t        qwaf.def
 ../snippets30.t        qwaf.qwaf
+../snippets30.t        btct.btct1
+../snippets31.t        btct.btct2
+../snippets31.t        btct.btct3
+../snippets31.t        btct.def
 ../snippets4.t gnu1.gnu
 ../snippets4.t gnu2.def
 ../snippets4.t gnu2.gnu
 ../snippets9.t rt98902.def
 ../snippets9.t rt98902.rt98902
 ../snippets9.t rt99961.def
-../snippets30.t        btct.btct1
-../snippets31.t        btct.btct2
-../snippets31.t        btct.btct3
-../snippets31.t        btct.def
+../snippets31.t        c424.c424
+../snippets31.t        c424.def
index 27f542100971506237f49049838e92e893058f09..e45368267ddb21640c1a0f6bbad2f6bbfbee9d14 100644 (file)
@@ -4,6 +4,8 @@
 #1 btct.btct2
 #2 btct.btct3
 #3 btct.def
+#4 c424.c424
+#5 c424.def
 
 # To locate test #13 you can search for its name or the string '#13'
 
@@ -23,6 +25,7 @@ BEGIN {
     $rparams = {
         'btct2' => "-btct=1 -atc -wtc=1",
         'btct3' => "-btct=1 -atc -wtc=1",
+        'c424'  => "-naws -qwaf",
         'def'   => "",
     };
 
@@ -45,6 +48,11 @@ $w->bind(
 $w->bind( '<Page_Down>' => xx);
 
 $lut = byte [ [ 0, 0, 0 ], [ 10, 1, 10 ], [ 2, 20, 20 ], [ 30, 30, 3 ], ];
+----------
+
+        'c424' => <<'----------',
+my @chars = qw(   | / - \ | / - \    );
+my @chars = qw(| / - \ | / - \ );
 ----------
     };
 
@@ -136,6 +144,24 @@ $w->bind( '<Page_Down>' => xx );
 $lut = byte [ [ 0, 0, 0 ], [ 10, 1, 10 ], [ 2, 20, 20 ], [ 30, 30, 3 ], ];
 #3...........
         },
+
+        'c424.c424' => {
+            source => "c424",
+            params => "c424",
+            expect => <<'#4...........',
+my @chars = qw( | / - \ | / - \ );
+my @chars = qw(| / - \ | / - \ );
+#4...........
+        },
+
+        'c424.def' => {
+            source => "c424",
+            params => "def",
+            expect => <<'#5...........',
+my @chars = qw(   | / - \ | / - \    );
+my @chars = qw(| / - \ | / - \ );
+#5...........
+        },
     };
 
     my $ntests = 0 + keys %{$rtests};