]> git.donarmstrong.com Git - perltidy.git/commitdiff
simplified sub flush
authorSteve Hancock <perltidy@users.sourceforge.net>
Wed, 5 Aug 2020 14:37:45 +0000 (07:37 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Wed, 5 Aug 2020 14:37:45 +0000 (07:37 -0700)
lib/Perl/Tidy/VerticalAligner.pm

index 2dad48f041559eb25961c3d2a98f242b128b1260..43b2bf8be176f542f1c0ad7b56080b361d207a53 100644 (file)
@@ -154,6 +154,23 @@ sub initialize {
     return $self;
 }
 
+sub flush {
+
+    # flush() is the external call to completely empty the pipeline.
+    my ($self) = @_;
+
+    # the buffer must be emptied first
+    $self->dump_valign_buffer();
+
+    # then any current group
+    $self->my_flush();
+
+    # then the cache, which may still contain text if there was
+    # no group
+    $self->my_flush_cache();
+    return;
+}
+
 sub initialize_for_new_group {
     my ($self) = @_;
 
@@ -1288,25 +1305,6 @@ sub dump_array {
     return;
 }
 
-# flush() sends the current Perl::Tidy::VerticalAligner group down the
-# pipeline to Perl::Tidy::FileWriter.
-
-# This is the external flush, which also empties the buffer and cache
-sub flush {
-    my ($self) = @_;
-
-    # the buffer must be emptied first, then any cached text
-    $self->dump_valign_buffer();
-
-    if ( $self->group_line_count() ) {
-        $self->my_flush();
-    }
-    else {
-        $self->my_flush_cache();
-    }
-    return;
-}
-
 sub level_change {
 
     # compute decrease in level when we remove $diff spaces from the