]> git.donarmstrong.com Git - perltidy.git/commitdiff
fixed bug with -okwl option and added test case
authorSteve Hancock <perltidy@users.sourceforge.net>
Sun, 24 May 2020 20:47:16 +0000 (13:47 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sun, 24 May 2020 20:47:16 +0000 (13:47 -0700)
lib/Perl/Tidy/Formatter.pm
lib/Perl/Tidy/VerticalAligner.pm
t/snippets/expect/outdent.def
t/snippets/expect/outdent.outdent1
t/snippets/expect/outdent.outdent2 [new file with mode: 0644]
t/snippets/outdent.in
t/snippets/outdent1.par
t/snippets/outdent2.par [new file with mode: 0644]
t/snippets/packing_list.txt
t/snippets19.t
t/snippets20.t

index 5acd53a34f870d6aab3cac54bc68ae7c6ade88a5..00f3b8724b6e3f34576e0bfd63bd480c1652a042 100644 (file)
@@ -5768,7 +5768,7 @@ EOM
 
     # implement outdenting preferences for keywords
     %outdent_keyword = ();
-    my @okw = split_words( $rOpts->{'outdent-keyword-okl'} );
+    my @okw = split_words( $rOpts->{'outdent-keyword-list'} );
     unless (@okw) {
         @okw = qw(next last redo goto return);    # defaults
     }
index 5fdb5e50bc14ad6442437f5738188610621645ad..df7f7a6b6541ff4fe7a8ea67d7aa8bf7c400601d 100644 (file)
@@ -2824,7 +2824,6 @@ sub delete_unmatched_tokens {
     BEGIN {
         my @q;
 
-        # These tokens with = may be deleted for vertical aligmnemt
         @q = ( ',', '=>', '#' );
         @is_comma_or_comment{@q} = (1) x scalar(@q);
 
index 3437dfae68bd7921c915fb8c19d72f79cdbb4b8d..ef0c38e2ed6273cf868d4c8a6d24c16bf3a1da10 100644 (file)
@@ -1,4 +1,3 @@
-        # test -nola -okw
         my $i;
       LOOP: while ( $i = <FOTOS> ) {
             chomp($i);
index 0952f6e595c1a8466ab1e33cadacb8e057323f67..b40c8297f14f4b592f241b50661fe88ddbfd8846 100644 (file)
@@ -1,4 +1,3 @@
-        # test -nola -okw
         my $i;
         LOOP: while ( $i = <FOTOS> ) {
             chomp($i);
diff --git a/t/snippets/expect/outdent.outdent2 b/t/snippets/expect/outdent.outdent2
new file mode 100644 (file)
index 0000000..2672ca8
--- /dev/null
@@ -0,0 +1,7 @@
+        my $i;
+      LOOP: while ( $i = <FOTOS> ) {
+            chomp($i);
+          next unless $i;
+            fixit($i);
+        }
+
index b76a6f9d78bc5734ceff2277f9fee7764cb67b95..ef0c38e2ed6273cf868d4c8a6d24c16bf3a1da10 100644 (file)
@@ -1,4 +1,3 @@
-# test -nola -okw
         my $i;
       LOOP: while ( $i = <FOTOS> ) {
             chomp($i);
index e2ba763181b8f1f40caf338f8ab09aa09e8cd62a..9a0aac17494477455d658b4bf339ee90bbf8bbb3 100644 (file)
@@ -1 +1,2 @@
+# test -nola -okw
 -nola -okw
diff --git a/t/snippets/outdent2.par b/t/snippets/outdent2.par
new file mode 100644 (file)
index 0000000..a02a855
--- /dev/null
@@ -0,0 +1,2 @@
+# test -okw and -okwl
+-okw -okwl='next'
index 7d6442646981bcabe1a1a87810cc33dd658c6b0b..f4ce326c1913198f33a99412eb18828034c6d9c1 100644 (file)
 ../snippets9.t rt98902.def
 ../snippets9.t rt98902.rt98902
 ../snippets9.t rt99961.def
+../snippets20.t        outdent.outdent2
index b40eb2e021d1a8fa2720a3c72b6c89a2e85549b1..693008ede4d2a25835295c7f640006dc2d279955 100644 (file)
@@ -50,7 +50,10 @@ BEGIN {
         'misc_tests' => <<'----------',
 -sts -ssc -sfs -nsak="my for" -ndsm
 ----------
-        'outdent1'     => "-nola -okw",
+        'outdent1' => <<'----------',
+# test -nola -okw
+-nola -okw
+----------
         'sbq0'         => "-sbq=0",
         'sbq2'         => "-sbq=2",
         'scbb'         => "-scbb",
@@ -108,7 +111,6 @@ my ( $a, $b, $c ) = @_;    # test -nsak="my for"
 ----------
 
         'outdent' => <<'----------',
-# test -nola -okw
         my $i;
       LOOP: while ( $i = <FOTOS> ) {
             chomp($i);
@@ -176,7 +178,6 @@ my( $a, $b, $c ) = @_ ;                                    # test -nsak="my for"
             source => "outdent",
             params => "def",
             expect => <<'#2...........',
-        # test -nola -okw
         my $i;
       LOOP: while ( $i = <FOTOS> ) {
             chomp($i);
@@ -191,7 +192,6 @@ my( $a, $b, $c ) = @_ ;                                    # test -nsak="my for"
             source => "outdent",
             params => "outdent1",
             expect => <<'#3...........',
-        # test -nola -okw
         my $i;
         LOOP: while ( $i = <FOTOS> ) {
             chomp($i);
index 4d98a77053d77e669b147908729cb1253d8a0358..6e201156ddbda416eff85a0034771bd2340117fb 100644 (file)
@@ -13,6 +13,7 @@
 #10 gnu6.gnu
 #11 git25.def
 #12 git25.git25
+#13 outdent.outdent2
 
 # To locate test #13 you can search for its name or the string '#13'
 
@@ -30,10 +31,14 @@ BEGIN {
     # BEGIN SECTION 1: Parameter combinations #
     ###########################################
     $rparams = {
-        'ce'     => "-cuddled-blocks",
-        'def'    => "",
-        'git25'  => "-l=0",
-        'gnu'    => "-gnu",
+        'ce'       => "-cuddled-blocks",
+        'def'      => "",
+        'git25'    => "-l=0",
+        'gnu'      => "-gnu",
+        'outdent2' => <<'----------',
+# test -okw and -okwl
+-okw -okwl='next'
+----------
         'space6' => <<'----------',
 -nwrs="+ - / *"
 -nwls="+ - / *"
@@ -101,6 +106,16 @@ my $mapping = [
         'foo10' => undef,
     };
 
+----------
+
+        'outdent' => <<'----------',
+        my $i;
+      LOOP: while ( $i = <FOTOS> ) {
+            chomp($i);
+            next unless $i;
+            fixit($i);
+        }
+
 ----------
 
         'space6' => <<'----------',
@@ -432,6 +447,20 @@ my $mapping = [
 
 #12...........
         },
+
+        'outdent.outdent2' => {
+            source => "outdent",
+            params => "outdent2",
+            expect => <<'#13...........',
+        my $i;
+      LOOP: while ( $i = <FOTOS> ) {
+            chomp($i);
+          next unless $i;
+            fixit($i);
+        }
+
+#13...........
+        },
     };
 
     my $ntests = 0 + keys %{$rtests};