]> git.donarmstrong.com Git - perltidy.git/commitdiff
fixed RT#131115, problem with -bli
authorSteve Hancock <perltidy@users.sourceforge.net>
Sun, 1 Dec 2019 01:46:52 +0000 (17:46 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sun, 1 Dec 2019 01:46:52 +0000 (17:46 -0800)
CHANGES.md
lib/Perl/Tidy/Formatter.pm
t/snippets/expect/rt131115.def [new file with mode: 0644]
t/snippets/expect/rt131115.rt131115 [new file with mode: 0644]
t/snippets/packing_list.txt
t/snippets/rt131115.in [new file with mode: 0644]
t/snippets/rt131115.par [new file with mode: 0644]
t/snippets16.t

index f4e5104beb3ab344e223dbd292e365d93868c0c1..bda5a03fae3ed5afb67acacbbe81eae56ed4b146 100644 (file)
@@ -2,6 +2,10 @@
 
 ## 2019 09 15.01
 
+    - Fixed issue RT#131115: -bli option not working correctly.
+      Closing braces were not indented in some cases due to a glitch
+      introduced in version 20181120.
+
     - Fixed issue RT#130394: Allow short nested blocks.  Given the following
 
         $factorial = sub { reduce { $a * $b } 1 .. 11 };
index 5eac7ad6ea2c4252102f4ed49642f542bb83c09c..40436416ab8318d3de9ef6f9de797843668adb42 100644 (file)
@@ -11009,7 +11009,14 @@ sub lookup_opening_indentation {
                 && defined($K_beg) )
             {
                 my $K_next_nonblank = $self->K_next_code($K_beg);
-                if ( defined($K_next_nonblank) ) {
+
+               # Patch for RT#131115: honor -bli flag at closing brace
+                my $is_bli =
+                     $rOpts_brace_left_and_indent
+                  && $block_type_to_go[$i_terminal]
+                  && $block_type_to_go[$i_terminal] =~ /$bli_pattern/o;
+
+                if ( !$is_bli && defined($K_next_nonblank) ) {
                     my $lev        = $rLL->[$K_beg]->[_LEVEL_];
                     my $level_next = $rLL->[$K_next_nonblank]->[_LEVEL_];
                     $adjust_indentation = 1 if ( $level_next < $lev );
diff --git a/t/snippets/expect/rt131115.def b/t/snippets/expect/rt131115.def
new file mode 100644 (file)
index 0000000..a834028
--- /dev/null
@@ -0,0 +1,7 @@
+# closing braces to be inteded with -bli
+sub a {
+    my %uniq;
+    foreach my $par (@_) {
+        $uniq{$par} = 1;
+    }
+}
diff --git a/t/snippets/expect/rt131115.rt131115 b/t/snippets/expect/rt131115.rt131115
new file mode 100644 (file)
index 0000000..7f61001
--- /dev/null
@@ -0,0 +1,9 @@
+# closing braces to be inteded with -bli
+sub a
+  {
+    my %uniq;
+    foreach my $par (@_)
+      {
+        $uniq{$par} = 1;
+      }
+  }
index 990ed502913ba8d420cbe0bd93274c18a7158f56..c2148c71bce85fb6816ae6c4433d6f3ab6733e18 100644 (file)
 ../snippets16.t        almost1.def
 ../snippets16.t        almost2.def
 ../snippets16.t        almost3.def
+../snippets16.t        rt130394.def
 ../snippets2.t angle.def
 ../snippets2.t arrows1.def
 ../snippets2.t arrows2.def
 ../snippets9.t rt98902.def
 ../snippets9.t rt98902.rt98902
 ../snippets9.t rt99961.def
-../snippets16.t        rt130394.def
+../snippets16.t        rt131115.def
+../snippets16.t        rt131115.rt131115
diff --git a/t/snippets/rt131115.in b/t/snippets/rt131115.in
new file mode 100644 (file)
index 0000000..a834028
--- /dev/null
@@ -0,0 +1,7 @@
+# closing braces to be inteded with -bli
+sub a {
+    my %uniq;
+    foreach my $par (@_) {
+        $uniq{$par} = 1;
+    }
+}
diff --git a/t/snippets/rt131115.par b/t/snippets/rt131115.par
new file mode 100644 (file)
index 0000000..3ee06bc
--- /dev/null
@@ -0,0 +1 @@
+-bli
index 7677af8b1ca54c6fe3860d76591947fa4b7fa0e9..5770bb58892d7476953e0ee86978b266c0158549 100644 (file)
@@ -12,6 +12,8 @@
 #9 almost2.def
 #10 almost3.def
 #11 rt130394.def
+#12 rt131115.def
+#13 rt131115.rt131115
 
 # To locate test #13 you can search for its name or the string '#13'
 
@@ -29,10 +31,11 @@ BEGIN {
     # BEGIN SECTION 1: Parameter combinations #
     ###########################################
     $rparams = {
-        'def'   => "",
-        'git10' => "-wn -ce -cbl=sort,map,grep",
-        'spp1'  => "-spp=1",
-        'spp2'  => "-spp=2",
+        'def'      => "",
+        'git10'    => "-wn -ce -cbl=sort,map,grep",
+        'rt131115' => "-bli",
+        'spp1'     => "-spp=1",
+        'spp2'     => "-spp=2",
     };
 
     ############################
@@ -100,6 +103,16 @@ $start   = $end     = $len = $ismut = $number = $allele_ori = $allele_mut =
         'rt130394' => <<'----------',
 # rt130394: keep on one line
 $factorial = sub { reduce { $a * $b } 1 .. 11 };
+----------
+
+        'rt131115' => <<'----------',
+# closing braces to be inteded with -bli
+sub a {
+    my %uniq;
+    foreach my $par (@_) {
+        $uniq{$par} = 1;
+    }
+}
 ----------
 
         'spp' => <<'----------',
@@ -245,6 +258,36 @@ sub head {
 $factorial = sub { reduce { $a * $b } 1 .. 11 };
 #11...........
         },
+
+        'rt131115.def' => {
+            source => "rt131115",
+            params => "def",
+            expect => <<'#12...........',
+# closing braces to be inteded with -bli
+sub a {
+    my %uniq;
+    foreach my $par (@_) {
+        $uniq{$par} = 1;
+    }
+}
+#12...........
+        },
+
+        'rt131115.rt131115' => {
+            source => "rt131115",
+            params => "rt131115",
+            expect => <<'#13...........',
+# closing braces to be inteded with -bli
+sub a
+  {
+    my %uniq;
+    foreach my $par (@_)
+      {
+        $uniq{$par} = 1;
+      }
+  }
+#13...........
+        },
     };
 
     my $ntests = 0 + keys %{$rtests};