]> git.donarmstrong.com Git - perltidy.git/commitdiff
fixed git#14, unwanted break at trailing 'or'
authorSteve Hancock <perltidy@users.sourceforge.net>
Wed, 19 Jun 2019 21:20:29 +0000 (14:20 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Wed, 19 Jun 2019 21:20:29 +0000 (14:20 -0700)
lib/Perl/Tidy/Formatter.pm
t/snippets/git14.in [new file with mode: 0644]

index 4ff7675f1b03b33cc5a866637f36043355178780..0fa94037cb7463092af7adfe0bc5d7b996e86f2f 100644 (file)
@@ -15879,17 +15879,20 @@ sub undo_forced_breakpoint_stack {
                           unless (
                             $this_line_is_semicolon_terminated
                             && (
+                                $type_ibeg_1 eq '}'
+                                || (
 
-                                # following 'if' or 'unless' or 'or'
-                                $type_ibeg_1 eq 'k'
-                                && $is_if_unless{ $tokens_to_go[$ibeg_1] }
-
-                                # important: only combine a very simple or
-                                # statement because the step below may have
-                                # combined a trailing 'and' with this or,
-                                # and we do not want to then combine
-                                # everything together
-                                && ( $iend_2 - $ibeg_2 <= 7 )
+                                    # following 'if' or 'unless' or 'or'
+                                    $type_ibeg_1 eq 'k'
+                                    && $is_if_unless{ $tokens_to_go[$ibeg_1] }
+
+                                    # important: only combine a very simple or
+                                    # statement because the step below may have
+                                    # combined a trailing 'and' with this or,
+                                    # and we do not want to then combine
+                                    # everything together
+                                    && ( $iend_2 - $ibeg_2 <= 7 )
+                                )
                             )
                           );
 
diff --git a/t/snippets/git14.in b/t/snippets/git14.in
new file mode 100644 (file)
index 0000000..08b0c1e
--- /dev/null
@@ -0,0 +1,5 @@
+# git#14; do not break at trailing 'or'
+$second = {
+    key1 => 'aaa',
+    key2 => 'bbb',
+} if $flag1 or $flag2;