From ae5853a0bd7da93b9ee52937785d1124315b5403 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Wed, 5 Aug 2020 07:37:45 -0700 Subject: [PATCH] simplified sub flush --- lib/Perl/Tidy/VerticalAligner.pm | 36 +++++++++++++++----------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/lib/Perl/Tidy/VerticalAligner.pm b/lib/Perl/Tidy/VerticalAligner.pm index 2dad48f0..43b2bf8b 100644 --- a/lib/Perl/Tidy/VerticalAligner.pm +++ b/lib/Perl/Tidy/VerticalAligner.pm @@ -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 -- 2.39.5