]> git.donarmstrong.com Git - perltidy.git/commitdiff
Do not align opening braces across ci level changes (c224)
authorSteve Hancock <perltidy@users.sourceforge.net>
Wed, 14 Jun 2023 18:24:17 +0000 (11:24 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Wed, 14 Jun 2023 18:24:17 +0000 (11:24 -0700)
docs/ci_update.md
lib/Perl/Tidy/Formatter.pm

index e729c8b291ed672fc6f6242b6ee8783e8445cee7..f1a6d51cdd6c283dcde267077e4df9ac5151bb7e 100644 (file)
@@ -350,3 +350,22 @@ of side comments.  The new version handles this correctly:
                   readdir(D)
             );
 ```
+
+A related change is that some undesirable alignments across changes in
+continuation indentation have been removed.  For example, here is an
+example of this issue as previously formatted:
+
+```
+        print $fh map { $_->[0] }
+          sort        { $a->[1] cmp $b->[1] || $a->[0] cmp $b->[0] }
+          map { my $f = lc $_; $f =~ s/[^a-z0-9\s]//g; [ $_, $f ] } @manifest;
+```
+
+The alignment of the ``map`` and ``sort`` braces produces an undesirable
+gap. The revised formatting avoids this:
+
+```
+    return sort grep { length($_) > 0 }
+        map { substr( $_, $length ) }
+        grep { starts_with( $_, $prefix . $text ) } @bookmarks;
+```
index 8b093fbb0c8e3555d16bd6c5035bd895b0f026a6..24f71b8ec9a035b86d5d7953c5700fe847b877e0 100644 (file)
@@ -28969,6 +28969,10 @@ sub xlp_tweak {
                     if ( $block_type =~ /^[A-Z]+$/ ) { $block_type = 'BEGIN' }
 
                     $tok .= $block_type;
+
+                    # Avoid aligning opening braces across leading ci level
+                    # changes by marking block type with _ci (issue c224)
+                    if ( $ci_levels_to_go[$ibeg] ) { $tok .= '_1' }
                 }
 
                 # Mark multiple copies of certain tokens with the copy number