From: Steve Hancock Date: Mon, 13 Dec 2021 19:58:49 +0000 (-0800) Subject: convert IndentationItem align_paren to align_seqno X-Git-Tag: 20211029.04~9 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=5f1659c29ad54db931e498cb9cdb541ab4fed321;p=perltidy.git convert IndentationItem align_paren to align_seqno --- diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index ab6aaef9..f1428fe5 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -16346,7 +16346,7 @@ sub correct_lp_indentation { # looking for indentation item for which we are aligning # with parens, braces, and brackets - next unless ( $indentation->get_align_paren() ); + next unless ( $indentation->get_align_seqno() ); # skip closed container on this line if ( $i > $ibeg ) { @@ -20363,7 +20363,7 @@ EOM # reduced as necessary when long lines are encountered or when # it becomes clear that we do not have a good list. my $available_spaces = 0; - my $align_paren = 0; + my $align_seqno = 0; my $excess = 0; my $last_nonblank_seqno; @@ -20483,7 +20483,7 @@ EOM $space_count = $min_gnu_indentation; $available_spaces = 0; } - $align_paren = 1; + $align_seqno = $last_nonblank_seqno; } } @@ -20522,7 +20522,7 @@ EOM ci_level => $ci_level, available_spaces => $available_spaces, lp_item_index => $lp_item_index, - align_paren => $align_paren, + align_seqno => $align_seqno, stack_depth => $max_lp_stack, K_begin_line => $K_begin_line, ); diff --git a/lib/Perl/Tidy/IndentationItem.pm b/lib/Perl/Tidy/IndentationItem.pm index 56cee144..c3b88f35 100644 --- a/lib/Perl/Tidy/IndentationItem.pm +++ b/lib/Perl/Tidy/IndentationItem.pm @@ -22,11 +22,10 @@ BEGIN { _available_spaces_ => $i++, _closed_ => $i++, _comma_count_ => $i++, - _sequence_number_ => $i++, _lp_item_index_ => $i++, _have_child_ => $i++, _recoverable_spaces_ => $i++, - _align_paren_ => $i++, + _align_seqno_ => $i++, _marked_ => $i++, _stack_depth_ => $i++, _K_begin_line_ => $i++, @@ -79,8 +78,8 @@ sub new { # recoverable_spaces => # how many spaces to the right # # we would like to move to get # # alignment (negative if left) - # align_paren => # do we want to try to align - # # with an opening structure? + # align_seqno => # if we are aligning with an opening structure, + # # this is its seqno # marked => # if visited by corrector logic # stack_depth => # indentation nesting depth # K_begin_line => # first token index K of this level @@ -96,7 +95,7 @@ sub new { $self->[_lp_item_index_] = $input_hash{lp_item_index}; $self->[_have_child_] = 0; $self->[_recoverable_spaces_] = 0; - $self->[_align_paren_] = $input_hash{align_paren}; + $self->[_align_seqno_] = $input_hash{align_seqno}; $self->[_marked_] = 0; $self->[_stack_depth_] = $input_hash{stack_depth}; $self->[_K_begin_line_] = $input_hash{K_begin_line}; @@ -188,8 +187,8 @@ sub decrease_available_spaces { return $self->[_available_spaces_]; } -sub get_align_paren { - return $_[0]->[_align_paren_]; +sub get_align_seqno { + return $_[0]->[_align_seqno_]; } sub get_recoverable_spaces { diff --git a/t/snippets/expect/gnu6.def b/t/snippets/expect/gnu6.def index cdacc483..a779feda 100644 --- a/t/snippets/expect/gnu6.def +++ b/t/snippets/expect/gnu6.def @@ -1,4 +1,10 @@ -# the closing braces should have the same position for these two hashes with -gnu + # These closing braces no longer have the same position with -gnu after an + # update 13 dec 2021 in which the vertical aligner zeros recoverable spaces. + # But adding the -xlp should make them all have the same indentation. + $var1 = { + 'foo10' => undef, + 'foo72' => ' ', + }; $var1 = { 'foo10' => undef, 'foo72' => ' @@ -9,4 +15,3 @@ ', 'foo10' => undef, }; - diff --git a/t/snippets/expect/gnu6.gnu b/t/snippets/expect/gnu6.gnu index af7299cf..e1676ab6 100644 --- a/t/snippets/expect/gnu6.gnu +++ b/t/snippets/expect/gnu6.gnu @@ -1,12 +1,17 @@ - # the closing braces should have the same position for these two hashes with -gnu + # These closing braces no longer have the same position with -gnu after an + # update 13 dec 2021 in which the vertical aligner zeros recoverable spaces. + # But adding the -xlp should make them all have the same indentation. + $var1 = { + 'foo10' => undef, + 'foo72' => ' ', + }; $var1 = { 'foo10' => undef, 'foo72' => ' ', - }; + }; $var2 = { 'foo72' => ' ', 'foo10' => undef, }; - diff --git a/t/snippets/gnu6.in b/t/snippets/gnu6.in index cdacc483..f85ccea5 100644 --- a/t/snippets/gnu6.in +++ b/t/snippets/gnu6.in @@ -1,4 +1,10 @@ -# the closing braces should have the same position for these two hashes with -gnu +# These closing braces no longer have the same position with -gnu after an +# update 13 dec 2021 in which the vertical aligner zeros recoverable spaces. +# But adding the -xlp should make them all have the same indentation. + $var1 = { + 'foo10' => undef, + 'foo72' => ' ', + }; $var1 = { 'foo10' => undef, 'foo72' => ' @@ -9,4 +15,3 @@ ', 'foo10' => undef, }; - diff --git a/t/snippets20.t b/t/snippets20.t index 58b30747..d5a80730 100644 --- a/t/snippets20.t +++ b/t/snippets20.t @@ -104,7 +104,13 @@ my $mapping = [ ---------- 'gnu6' => <<'----------', -# the closing braces should have the same position for these two hashes with -gnu +# These closing braces no longer have the same position with -gnu after an +# update 13 dec 2021 in which the vertical aligner zeros recoverable spaces. +# But adding the -xlp should make them all have the same indentation. + $var1 = { + 'foo10' => undef, + 'foo72' => ' ', + }; $var1 = { 'foo10' => undef, 'foo72' => ' @@ -115,7 +121,6 @@ my $mapping = [ ', 'foo10' => undef, }; - ---------- 'hanging_side_comments3' => <<'----------', @@ -409,7 +414,13 @@ else { source => "gnu6", params => "def", expect => <<'#9...........', -# the closing braces should have the same position for these two hashes with -gnu + # These closing braces no longer have the same position with -gnu after an + # update 13 dec 2021 in which the vertical aligner zeros recoverable spaces. + # But adding the -xlp should make them all have the same indentation. + $var1 = { + 'foo10' => undef, + 'foo72' => ' ', + }; $var1 = { 'foo10' => undef, 'foo72' => ' @@ -420,7 +431,6 @@ else { ', 'foo10' => undef, }; - #9........... }, @@ -428,18 +438,23 @@ else { source => "gnu6", params => "gnu", expect => <<'#10...........', - # the closing braces should have the same position for these two hashes with -gnu + # These closing braces no longer have the same position with -gnu after an + # update 13 dec 2021 in which the vertical aligner zeros recoverable spaces. + # But adding the -xlp should make them all have the same indentation. + $var1 = { + 'foo10' => undef, + 'foo72' => ' ', + }; $var1 = { 'foo10' => undef, 'foo72' => ' ', - }; + }; $var2 = { 'foo72' => ' ', 'foo10' => undef, }; - #10........... },