]> git.donarmstrong.com Git - perltidy.git/commitdiff
fix to allow simultaneous -dp and -tp
authorSteve Hancock <perltidy@users.sourceforge.net>
Sat, 25 Apr 2020 13:40:30 +0000 (06:40 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sat, 25 Apr 2020 13:40:30 +0000 (06:40 -0700)
lib/Perl/Tidy/Formatter.pm

index ba7b136d2a535aea51125685cf8e0bb21e4c52ca..069e31a45b86c8eed227add917ac1998a979a425 100644 (file)
@@ -722,6 +722,9 @@ sub new {
         rvalid_self_keys           => [],              # for checking
         valign_batch_count         => 0,
         length_function            => $length_function,
+        sink_object                => $sink_object,
+        logger_object              => $logger_object,
+        file_writer_object         => $file_writer_object,
     };
     my @valid_keys = keys %{$formatter_self};
     $formatter_self->{rvalid_self_keys} = \@valid_keys;
@@ -1415,6 +1418,7 @@ sub break_lines {
 
     my $self                       = shift;
     my $rlines                     = $self->{rlines};
+    my $sink_object                = $self->{sink_object};
     my $rOpts_keep_old_blank_lines = $rOpts->{'keep-old-blank-lines'};
 
     # Note for RT#118553, leave only one newline at the end of a file.
@@ -1542,14 +1546,12 @@ sub break_lines {
 
             # set special flags
             my $skip_line = 0;
-            my $tee_line  = 0;
             if ( $line_type =~ /^POD/ ) {
 
                 # Pod docs should have a preceding blank line.  But stay
                 # out of __END__ and __DATA__ sections, because
                 # the user may be using this section for any purpose whatsoever
                 if ( $rOpts->{'delete-pod'} ) { $skip_line = 1; }
-                if ( $rOpts->{'tee-pod'} )    { $tee_line = 1; }
                 if ( $rOpts->{'trim-pod'} )   { $input_line =~ s/\s+$// }
                 if (   !$skip_line
                     && !$in_format_skipping_section
@@ -1569,9 +1571,11 @@ sub break_lines {
 
             # write unindented non-code line
             if ( !$skip_line ) {
-                if ($tee_line) { $file_writer_object->tee_on() }
                 $self->write_unindented_line($input_line);
-                if ($tee_line) { $file_writer_object->tee_off() }
+            }
+
+            if ( $rOpts->{'tee-pod'} ) {
+                $sink_object->write_tee_line($input_line);
             }
         }
     }
@@ -5699,14 +5703,6 @@ sub check_options {
         Exit(0);
     }
 
-    if ( $rOpts->{'delete-pod'} && $rOpts->{'tee-pod'} ) {
-        Warn(<<EOM);
-Options '--tee-pod' and '--delete-pod' conflict; Do them in separate runs.
-Turning off '--delete-pod' for this run to avoid data loss.
-EOM
-        $rOpts->{'delete-pod'} = 0;
-    }
-
     if ( $rOpts->{'line-up-parentheses'} ) {
 
         if (   $rOpts->{'indent-only'}