From 79a67a091bb2e60ea4b6c52a7a7f19b7fff84e9c Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Wed, 19 Jun 2019 14:20:29 -0700 Subject: [PATCH] fixed git#14, unwanted break at trailing 'or' --- lib/Perl/Tidy/Formatter.pm | 23 +++++++++++++---------- t/snippets/git14.in | 5 +++++ 2 files changed, 18 insertions(+), 10 deletions(-) create mode 100644 t/snippets/git14.in 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; -- 2.39.5