From 1fbc381265208c5013a49daa60a3683d61432da6 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Thu, 5 Nov 2020 06:43:49 -0800 Subject: [PATCH] fix issue git #45, -wn and -vtc=n now work together --- lib/Perl/Tidy/Formatter.pm | 10 ++++++---- t/snippets/git45.in | 22 ++++++++++++++++++++++ t/snippets/git45.par | 1 + 3 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 t/snippets/git45.in create mode 100644 t/snippets/git45.par diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index cbc219e4..ff8a487b 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -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 index 00000000..c8261fe7 --- /dev/null +++ b/t/snippets/git45.in @@ -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 index 00000000..d5260269 --- /dev/null +++ b/t/snippets/git45.par @@ -0,0 +1 @@ +-vtc=1 -wn -- 2.39.5