From: Steve Hancock Date: Sun, 27 Dec 2020 14:49:11 +0000 (-0800) Subject: improved vertical alignment of some edge cases X-Git-Tag: 20210111~20 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=035d2b747d7eeaf57d27269573ddfb512dad1eca;p=perltidy.git improved vertical alignment of some edge cases --- diff --git a/CHANGES.md b/CHANGES.md index b3f33d12..3f8edfbb 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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. diff --git a/lib/Perl/Tidy/VerticalAligner.pm b/lib/Perl/Tidy/VerticalAligner.pm index 2ec5bc99..8e4d0805 100644 --- a/lib/Perl/Tidy/VerticalAligner.pm +++ b/lib/Perl/Tidy/VerticalAligner.pm @@ -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; } diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index acfd3fe6..cc5305bd 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -2,6 +2,42 @@ =over 4 +=item B + +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 The -lp formatting style often does not work well when lists contain multiline qw