From: Steve Hancock Date: Mon, 7 Sep 2020 23:36:43 +0000 (-0700) Subject: patched for undefined variable X-Git-Tag: 20200907.01~46 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=4ca88d7d93355471816e2248e179060e2b6fd9f7;p=perltidy.git patched for undefined variable --- diff --git a/lib/Perl/Tidy/VerticalAligner.pm b/lib/Perl/Tidy/VerticalAligner.pm index 4d985eb7..d021a3ac 100644 --- a/lib/Perl/Tidy/VerticalAligner.pm +++ b/lib/Perl/Tidy/VerticalAligner.pm @@ -1652,6 +1652,11 @@ EOM # remember the column of the terminal ? or { to match with $col_matching_terminal = $base_line->get_column($j_terminal_match); + + # FIXME: It can happen that $j_terminal_match becomes incorrect if + # delete_unmatched_tokens deletes some tokens and doesn't update it. + # This needs to be fixed. For now just ignore it. + $col_matching_terminal = 0 unless defined($col_matching_terminal); } # ------------------------------------------------------------- @@ -1713,10 +1718,17 @@ EOM if ( $group_line_count == 1 ) { $base_line = $new_line; my $col_now = $base_line->get_column($j_terminal_match); + + # FIXME: It can happen that $j_terminal_match becomes + # incorrect if delete_unmatched_tokens deletes some tokens + # and doesn't update it. This needs to be fixed. For now + # just ignore it. + $col_now = 0 unless defined($col_now); + my $pad = $col_matching_terminal - $col_now; my $padding_available = $base_line->get_available_space_on_right(); - if ( $pad > 0 && $pad <= $padding_available ) { + if ( $col_now && $pad > 0 && $pad <= $padding_available ) { $base_line->increase_field_width( $j_terminal_match, $pad ); }