]> git.donarmstrong.com Git - perltidy.git/commitdiff
fix issue git #45, -wn and -vtc=n now work together
authorSteve Hancock <perltidy@users.sourceforge.net>
Thu, 5 Nov 2020 14:43:49 +0000 (06:43 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Thu, 5 Nov 2020 14:43:49 +0000 (06:43 -0800)
lib/Perl/Tidy/Formatter.pm
t/snippets/git45.in [new file with mode: 0644]
t/snippets/git45.par [new file with mode: 0644]

index cbc219e4d2a8e757db9a912f5b479732884e9d25..ff8a487b647f31732737959da6dc4b503ad36426 100644 (file)
@@ -18984,10 +18984,11 @@ sub set_vertical_tightness_flags {
             my $cvt = $closing_vertical_tightness{$token_next};
             if (
 
-                # never append a trailing line like   )->pack(
-                # because it will throw off later alignment
+               # Never append a trailing line like   ')->pack(' because it
+               # will throw off later alignment.  So this line must start at a
+               # deeper level than the next line (fix1 for welding, git #45).
                 (
-                    $nesting_depth_to_go[$ibeg_next] ==
+                    $nesting_depth_to_go[$ibeg_next] >=
                     $nesting_depth_to_go[ $iend_next + 1 ] + 1
                 )
                 && (
@@ -19014,7 +19015,8 @@ sub set_vertical_tightness_flags {
                         @types_to_go[ $ibeg_next + 1 .. $ibeg_next + 2 ] );
 
                     # append closing token if followed by comment or ';'
-                    if ( $str =~ /^b?[#;]/ ) { $ok = 1 }
+                    # or another closing token (fix2 for welding, git #45)
+                    if ( $str =~ /^b?[\)\]\}R#;]/ ) { $ok = 1 }
                 }
 
                 if ($ok) {
diff --git a/t/snippets/git45.in b/t/snippets/git45.in
new file mode 100644 (file)
index 0000000..c8261fe
--- /dev/null
@@ -0,0 +1,22 @@
+# git#45 -vtc=n and -wn were not working together
+if (
+    $self->_add_fqdn_host(
+        name  => $name,
+        realm => $realm
+    )
+  )
+{
+    ...;
+}
+
+# do not stack )->pack(
+my $hlist = $control::control->Scrolled(
+    'HList',
+    drawbranch  => 1,
+    width       => 20,
+    -scrollbars => 'w'
+)->pack(
+    -side   => 'bottom',
+    -expand => 1
+);
+
diff --git a/t/snippets/git45.par b/t/snippets/git45.par
new file mode 100644 (file)
index 0000000..d526026
--- /dev/null
@@ -0,0 +1 @@
+-vtc=1 -wn