From 077edb76294892aa79bdb80fef3be9d7609cc061 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Tue, 4 Dec 2018 22:15:27 -0800 Subject: [PATCH] minor fix --- lib/Perl/Tidy/Formatter.pm | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 9622f6eb..dcaa3033 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -1031,20 +1031,23 @@ sub keyword_group_scan { } } - # - Do not put a blank before a line of different level - # - Do not put a blank line if we ended the search badly - # - Do not put a blank at the end of the file - # - Do not put a blank line before a hanging side comment - my $level = $rLL->[$K_first]->[_LEVEL_]; - my $ci_level = $rLL->[$K_first]->[_CI_LEVEL_]; - - if ( $level == $level_beg - && $ci_level == 0 - && !$bad_ending - && $iend < @{$rlines} - && $CODE_type ne 'HSC' ) - { - $rhash_of_desires->{$iend} = $Opt_blanks_after; + if ( defined($K_first) ) { + + # - Do not put a blank before a line of different level + # - Do not put a blank line if we ended the search badly + # - Do not put a blank at the end of the file + # - Do not put a blank line before a hanging side comment + my $level = $rLL->[$K_first]->[_LEVEL_]; + my $ci_level = $rLL->[$K_first]->[_CI_LEVEL_]; + + if ( $level == $level_beg + && $ci_level == 0 + && !$bad_ending + && $iend < @{$rlines} + && $CODE_type ne 'HSC' ) + { + $rhash_of_desires->{$iend} = $Opt_blanks_after; + } } } $sub_group->(); @@ -1086,6 +1089,8 @@ sub keyword_group_scan { my $i = -1; foreach my $line_of_tokens ( @{$rlines} ) { $i++; + $K_first = undef; + $K_last = undef; my $line_type = $line_of_tokens->{_line_type}; $CODE_type = ""; if ( $line_type ne 'CODE' ) { $end_group->(); next } -- 2.39.5