]> git.donarmstrong.com Git - perltidy.git/commitdiff
improved vertical alignment of some edge cases
authorSteve Hancock <perltidy@users.sourceforge.net>
Sun, 27 Dec 2020 14:49:11 +0000 (06:49 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sun, 27 Dec 2020 14:49:11 +0000 (06:49 -0800)
CHANGES.md
lib/Perl/Tidy/VerticalAligner.pm
local-docs/BugLog.pod

index b3f33d128a339c1d0c9c04a1d989e365a47e43be..3f8edfbbaba97fa35ce067dd13276e3931664a9f 100644 (file)
@@ -2,17 +2,27 @@
 
 ## 2020 12 07 xx
 
+    - Fixed issue git #51, in which closing quote pattern delimiters not always
+    following the settings specified by the --closing-token-indentation=n settings.
+    Now qw closing delimiters ')', '}' and ']' follow these flags, and the
+    delimiter '>' follows the flag for ')'.  Other qw pattern delimiters remain
+    indented as the are now.  This change will cause some small formatting changes
+    in some existing programs.
+
     - Fixed issue git #49, -se breaks warnings exit status behavior.
     The exit status flag was not always being set when the -se flag was set.
 
+    - Some minor improvements have been made to the rules for formatting
+    some edge vertical alignment cases, usually involving two dissimilar lines.
+
     - Some minor issues that the average user would not encounter were found
-      and fixed. They can be seen in the more complete list of updates at 
+      and fixed. They can be seen in the more complete list of updates at
 
            https://github.com/perltidy/perltidy/blob/master/local-docs/BugLog.pod
 
 ## 2020 12 07
 
-    - Fixed issue git #47, incorrect welding of anonymous subs. 
+    - Fixed issue git #47, incorrect welding of anonymous subs.
       An incorrect weld format was being made when the --weld-nested-containers option
       (-wn) was used in to format a function which returns a list of anonymous subs.
       For example, the following snippet was incorrectly being welded.
index 2ec5bc997ca82926fb65441b4423d19ad1bac47a..8e4d080501b97cf871bbfdd55a55681fc6237009 100644 (file)
@@ -1772,9 +1772,20 @@ sub two_line_pad {
     my ( $lenmin, $lenmax ) =
       $lensum >= $lensum_m ? ( $lensum_m, $lensum ) : ( $lensum, $lensum_m );
 
-    # all or none:
+    my $patterns_match;
+    if ( $line_m->get_list_type() && $line->get_list_type() ) {
+        $patterns_match = 1;
+        my $rpatterns_m = $line_m->get_rpatterns();
+        my $rpatterns   = $line->get_rpatterns();
+        for ( my $i = 0 ; $i <= $imax_min ; $i++ ) {
+            my $pat   = $rpatterns->[$i];
+            my $pat_m = $rpatterns_m->[$i];
+            if ( $pat ne $pat_m ) { $patterns_match = 0; last }
+        }
+    }
+
     my $pad_max = $lenmax;
-    if ( $lenmax > 2 * $lenmin ) { $pad_max = 0 }
+    if ( !$patterns_match && $lenmax > 2 * $lenmin ) { $pad_max = 0 }
 
     return $pad_max;
 }
index acfd3fe61fd5ce197bfc01a8af508cee9b483668..cc5305bd640e6a5f1a2732a14e932215715c9f2d 100644 (file)
@@ -2,6 +2,42 @@
 
 =over 4
 
+=item B<Improved vertical alignment of some edge cases>
+
+The existing rules for aligning two lines with very different lengths were
+rejecting some good alignments, such as the first line of numbers in the example
+below:
+
+    # OLD:
+    @gg_3 = (
+        [
+            0.0, 1.360755E-2, 9.569446E-4, 9.569446E-4,
+            1.043498E-3, 1.043498E-3
+        ],
+        [
+            9.569446E-4, 9.569446E-4, 0.0, 7.065964E-5,
+            1.422811E-4, 1.422811E-4
+        ],
+        ...
+    );
+
+    # NEW:
+    @gg_3 = (
+        [
+            0.0,         1.360755E-2, 9.569446E-4, 9.569446E-4,
+            1.043498E-3, 1.043498E-3
+        ],
+        [
+            9.569446E-4, 9.569446E-4, 0.0, 7.065964E-5,
+            1.422811E-4, 1.422811E-4
+        ],
+        ...
+    );
+
+The rule in sub 'two_line_pad' was updated to allow alignment of any lists
+if the patterns match exactly (all numbers in this case).  Updated
+27-Dec-2020.
+
 =item B<Avoid -lp style formatting of lists containing multiline qw quotes>
 
 The -lp formatting style often does not work well when lists contain multiline qw