From: Steve Hancock Date: Wed, 19 Jun 2019 21:20:29 +0000 (-0700) Subject: fixed git#14, unwanted break at trailing 'or' X-Git-Tag: 20190915~15 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=79a67a091bb2e60ea4b6c52a7a7f19b7fff84e9c;p=perltidy.git fixed git#14, unwanted break at trailing 'or' --- diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 4ff7675f..0fa94037 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -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 index 00000000..08b0c1ea --- /dev/null +++ b/t/snippets/git14.in @@ -0,0 +1,5 @@ +# git#14; do not break at trailing 'or' +$second = { + key1 => 'aaa', + key2 => 'bbb', +} if $flag1 or $flag2;