From: Steve Hancock Date: Tue, 3 Aug 2021 02:44:03 +0000 (-0700) Subject: eliminate variable 'level_jump' from vertical aligner X-Git-Tag: 20210717.02~65 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=46ba889c0d6bfa2df7c101bb0501d54fde9cae89;p=perltidy.git eliminate variable 'level_jump' from vertical aligner --- diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 5c801e73..33bc9f89 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -19165,10 +19165,7 @@ sub send_lines_to_vertical_aligner { my $Kend_code = $batch_CODE_type && $batch_CODE_type ne 'VER' ? undef : $Kend; - # We need two slightly different definitions of level jump: - # $level_jump is the 'slevel' jump across line starts for valign # $ljump is a level jump needed by 'sub set_adjusted_indentation' - my $level_jump = 0; my $ljump = 0; # Get some vars on line [n+1], if any: @@ -19179,8 +19176,6 @@ sub send_lines_to_vertical_aligner { $token_beg_next = $rLL->[$Kbeg_next]->[_TOKEN_]; $type_end_next = $rLL->[$Kend_next]->[_TYPE_]; $ljump = $rLL->[$Kbeg_next]->[_LEVEL_] - $rLL->[$Kend]->[_LEVEL_]; - $level_jump = - $rLL->[$Kbeg_next]->[_SLEVEL_] - $rLL->[$Kbeg]->[_SLEVEL_]; } else { @@ -19190,8 +19185,6 @@ sub send_lines_to_vertical_aligner { if ( defined($Kbeg_next) ) { $ljump = $rLL->[$Kbeg_next]->[_LEVEL_] - $rLL->[$Kend]->[_LEVEL_]; - $level_jump = - $rLL->[$Kbeg_next]->[_SLEVEL_] - $rLL->[$Kbeg]->[_SLEVEL_]; } } @@ -19349,7 +19342,6 @@ EOM $rvalign_hash->{outdent_long_lines} = $outdent_long_lines; $rvalign_hash->{is_terminal_ternary} = $is_terminal_ternary; $rvalign_hash->{rvertical_tightness_flags} = $rvertical_tightness_flags; - $rvalign_hash->{level_jump} = $level_jump; $rvalign_hash->{rfields} = $rfields; $rvalign_hash->{rpatterns} = $rpatterns; $rvalign_hash->{rtokens} = $rtokens; diff --git a/lib/Perl/Tidy/VerticalAligner.pm b/lib/Perl/Tidy/VerticalAligner.pm index a5223e54..206fc835 100644 --- a/lib/Perl/Tidy/VerticalAligner.pm +++ b/lib/Perl/Tidy/VerticalAligner.pm @@ -406,7 +406,6 @@ sub valign_input { my $outdent_long_lines = $rline_hash->{outdent_long_lines}; my $is_terminal_ternary = $rline_hash->{is_terminal_ternary}; my $rvertical_tightness_flags = $rline_hash->{rvertical_tightness_flags}; - my $level_jump = $rline_hash->{level_jump}; my $rfields = $rline_hash->{rfields}; my $rtokens = $rline_hash->{rtokens}; my $rpatterns = $rline_hash->{rpatterns}; @@ -421,9 +420,6 @@ sub valign_input { # The index '$Kend' is a value which passed along with the line text to sub # 'write_code_line' for a convergence check. - # NOTE: the coding has been revised to avoid use of '$level_jump'. - # Eventually it can be eliminated as a call parameter. - # number of fields is $jmax # number of tokens between fields is $jmax-1 my $jmax = @{$rfields} - 1; @@ -503,7 +499,7 @@ sub valign_input { if ( $cached_line_type == 3 && !$self->group_line_count() && $cached_line_flag < 2 - && !$is_balanced_line ) ##&& $level_jump != 0 ) + && !$is_balanced_line ) { set_cached_line_valid(0); } @@ -581,7 +577,7 @@ sub valign_input { # alignment of the '{'. if ( $rfields->[0] eq 'else ' && @{$rgroup_lines} - && $is_balanced_line ) ##&& $level_jump == 0 ) + && $is_balanced_line ) { $j_terminal_match = @@ -712,12 +708,6 @@ sub valign_input { $self->_flush_group_lines(-1); } - ## OLD CODING: - ## Force break after jump to lower level - ## if ( $level_jump < 0 ) { - ## $self->_flush_group_lines($level_jump); - ## } - # -------------------------------------------------------------------- # Some old debugging stuff # -------------------------------------------------------------------- @@ -1386,6 +1376,7 @@ sub _flush_group_lines { # $level_jump = $next_level-$group_level, if known # = undef if not known + # Note: only the sign of the jump is needed my $rgroup_lines = $self->[_rgroup_lines_]; return unless ( @{$rgroup_lines} );