]> git.donarmstrong.com Git - perltidy.git/commitdiff
convert IndentationItem align_paren to align_seqno
authorSteve Hancock <perltidy@users.sourceforge.net>
Mon, 13 Dec 2021 19:58:49 +0000 (11:58 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Mon, 13 Dec 2021 19:58:49 +0000 (11:58 -0800)
lib/Perl/Tidy/Formatter.pm
lib/Perl/Tidy/IndentationItem.pm
t/snippets/expect/gnu6.def
t/snippets/expect/gnu6.gnu
t/snippets/gnu6.in
t/snippets20.t

index ab6aaef910a5e5ccadb4c0fff849821adff31653..f1428fe5b36d00b3ddae5393bb30648d5c7aec04 100644 (file)
@@ -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,
                         );
index 56cee1449b71acbc50c8faf51f82cce13f33b299..c3b88f351c001ce84afff7ea5b6a7f77f3871419 100644 (file)
@@ -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 {
index cdacc48322c40ea865f8f3f33692564091ba07ef..a779fedaae61f767dc0369656d36513cadc2dd51 100644 (file)
@@ -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,
     };
-
index af7299cf27150dfc796a9754af7b355f9dbfe84b..e1676ab62ea085d5d9705baff329b16c350d92e2 100644 (file)
@@ -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,
             };
-
index cdacc48322c40ea865f8f3f33692564091ba07ef..f85ccea54ee2400596a4b04f104611ccbe8cb18f 100644 (file)
@@ -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,
     };
-
index 58b30747a9a52664602b9c5385c5cb1ff1ee2683..d5a8073015e4b08761d3b62fffce082219e16c00 100644 (file)
@@ -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...........
         },