From 8f7e4cb0e4cd530ae662b3b0a2fbcb8102465022 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Mon, 7 Sep 2020 19:56:53 -0700 Subject: [PATCH] fixed bug where long line with here target got broken --- lib/Perl/Tidy/Formatter.pm | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 8c2bdfbf..305b6478 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -3056,6 +3056,18 @@ sub respace_tokens { $rtoken_vars->[_TOKEN_] = $token; } + # change code type to be NIN at a here target to avoid breaking the line + elsif ( $type eq 'h' ) { + + # 'VB' = Verbatim - line goes out verbatim + # 'FS' = Format Skipping - line goes out verbatim, no blanks + # 'IO' = Indent Only - only indentation may be changed + unless ( $CODE_type && $CODE_type =~ /^(VB|FS|IO)$/ ) { + $CODE_type = 'NIN'; + $line_of_tokens->{_code_type} = $CODE_type; + } + } + # patch to add space to something like "x10" # This avoids having to split this token in the pre-tokenizer elsif ( $type eq 'n' ) { @@ -7736,6 +7748,7 @@ sub copy_token_as_type { } $no_internal_newlines = 1 - $rOpts_add_newlines; + $no_internal_newlines ||= $CODE_type eq 'NIN'; $side_comment_follows = 0; my $is_comment = ( $K_first == $K_last && $rLL->[$K_first]->[_TYPE_] eq '#' ); -- 2.39.5