]> git.donarmstrong.com Git - perltidy.git/commitdiff
fixed bug where long line with here target got broken
authorSteve Hancock <perltidy@users.sourceforge.net>
Tue, 8 Sep 2020 02:56:53 +0000 (19:56 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Tue, 8 Sep 2020 02:56:53 +0000 (19:56 -0700)
lib/Perl/Tidy/Formatter.pm

index 8c2bdfbf289074bfd66329cd24df63f216fed5f5..305b647866c7f53b933bf792da4ee9e341e16f77 100644 (file)
@@ -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 '#' );