From: Steve Hancock Date: Sun, 13 Oct 2019 13:48:46 +0000 (-0700) Subject: fixed some two line alignments X-Git-Tag: 20191203~20 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=c887b3757c25da20538d0dd70c03462b967830b2;p=perltidy.git fixed some two line alignments --- diff --git a/CHANGES.md b/CHANGES.md index 1c877c6e..ed17d7c6 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,7 +2,7 @@ ## 2019 09 15.01 - - implement issue RT#130640: Allow different subroutine keywords. + - Implement issue RT#130640: Allow different subroutine keywords. Added a flag --sub-alias-list=s or -sal=s, where s is a string with one or more aliases for 'sub', separated by spaces or commas. For example, @@ -28,9 +28,12 @@ sub usage(); # i=1 [default; follows input] sub usage (); # i=2 [space] - - fixed issue git#16, minor vertical alignment issue. + - Fixed issue git#16, minor vertical alignment issue. + + - Fixed issue git#10, minor conflict of -wn and -ce + + - Improved some vertical alignments involving two lines. - - fixed issue git#10, minor conflict of -wn and -ce ## 2019 09 15 diff --git a/lib/Perl/Tidy/VerticalAligner.pm b/lib/Perl/Tidy/VerticalAligner.pm index 41795d0d..bad2999f 100644 --- a/lib/Perl/Tidy/VerticalAligner.pm +++ b/lib/Perl/Tidy/VerticalAligner.pm @@ -2447,10 +2447,9 @@ sub delete_unmatched_tokens { } } - # Leave two lines alone unless they are an if/else or ternary pair. - # Alignment of just two lines can be annoying, so it is best to let the - # two-line rules decide if they should be aligned. - next if ( $nlines <= 2 && !$is_full_block ); + # OLD: Leave two lines alone unless they are an if/else or ternary. + # NEW: Treat two lines the same as longer runs; results are better. + ## next if ( $nlines <= 2 && !$is_full_block ); # remove unwanted alignment tokens for ( my $jj = $jbeg ; $jj <= $jend ; $jj++ ) { diff --git a/t/snippets/align21.in b/t/snippets/align21.in index 216bed19..37703797 100644 --- a/t/snippets/align21.in +++ b/t/snippets/align21.in @@ -1,3 +1,11 @@ # two lines with large gap but same lhs pattern so align equals local (@pieces) = split( /\./, $filename, 2 ); local ($just_dir_and_base) = $pieces[0]; + +# two lines with 3 alignment tokens +$expect = "1$expect" if $expect =~ /^e/i; +$p = "1$p" if defined $p and $p =~ /^e/i; + +# two lines where alignment causes a large gap +is( eval { sysopen( my $ro, $foo, &O_RDONLY | $TAINT0 ) }, undef ); +is( $@, '' ); diff --git a/t/snippets/expect/align21.def b/t/snippets/expect/align21.def index 216bed19..be44c4f3 100644 --- a/t/snippets/expect/align21.def +++ b/t/snippets/expect/align21.def @@ -1,3 +1,11 @@ # two lines with large gap but same lhs pattern so align equals local (@pieces) = split( /\./, $filename, 2 ); local ($just_dir_and_base) = $pieces[0]; + +# two lines with 3 alignment tokens +$expect = "1$expect" if $expect =~ /^e/i; +$p = "1$p" if defined $p and $p =~ /^e/i; + +# two lines where alignment causes a large gap +is( eval { sysopen( my $ro, $foo, &O_RDONLY | $TAINT0 ) }, undef ); +is( $@, '' ); diff --git a/t/snippets/expect/kgb3.def b/t/snippets/expect/kgb3.def index 0f805444..5cdbe88c 100644 --- a/t/snippets/expect/kgb3.def +++ b/t/snippets/expect/kgb3.def @@ -1,5 +1,5 @@ #!/usr/bin/perl -w -use strict; # with -kgb, no break after hash bang +use strict; # with -kgb, no break after hash bang our ( @Changed, $TAP ); # break after isolated 'our' use File::Compare; use Symbol; diff --git a/t/snippets/expect/kgb3.kgb b/t/snippets/expect/kgb3.kgb index 61e1c6d5..159b0c26 100644 --- a/t/snippets/expect/kgb3.kgb +++ b/t/snippets/expect/kgb3.kgb @@ -1,5 +1,5 @@ #!/usr/bin/perl -w -use strict; # with -kgb, no break after hash bang +use strict; # with -kgb, no break after hash bang our ( @Changed, $TAP ); # break after isolated 'our' use File::Compare; diff --git a/t/snippets/packing_list.txt b/t/snippets/packing_list.txt index e9032c0a..5076cc6d 100644 --- a/t/snippets/packing_list.txt +++ b/t/snippets/packing_list.txt @@ -139,6 +139,8 @@ ../snippets16.t spp.spp1 ../snippets16.t spp.spp2 ../snippets16.t git16.def +../snippets16.t git10.def +../snippets16.t git10.git10 ../snippets2.t angle.def ../snippets2.t arrows1.def ../snippets2.t arrows2.def @@ -299,5 +301,3 @@ ../snippets9.t rt98902.def ../snippets9.t rt98902.rt98902 ../snippets9.t rt99961.def -../snippets16.t git10.def -../snippets16.t git10.git10 diff --git a/t/snippets13.t b/t/snippets13.t index b575f103..8d7bccdc 100644 --- a/t/snippets13.t +++ b/t/snippets13.t @@ -116,6 +116,14 @@ $t = 1000000; # two lines with large gap but same lhs pattern so align equals local (@pieces) = split( /\./, $filename, 2 ); local ($just_dir_and_base) = $pieces[0]; + +# two lines with 3 alignment tokens +$expect = "1$expect" if $expect =~ /^e/i; +$p = "1$p" if defined $p and $p =~ /^e/i; + +# two lines where alignment causes a large gap +is( eval { sysopen( my $ro, $foo, &O_RDONLY | $TAINT0 ) }, undef ); +is( $@, '' ); ---------- 'align22' => <<'----------', @@ -336,6 +344,14 @@ $t = 1000000; # two lines with large gap but same lhs pattern so align equals local (@pieces) = split( /\./, $filename, 2 ); local ($just_dir_and_base) = $pieces[0]; + +# two lines with 3 alignment tokens +$expect = "1$expect" if $expect =~ /^e/i; +$p = "1$p" if defined $p and $p =~ /^e/i; + +# two lines where alignment causes a large gap +is( eval { sysopen( my $ro, $foo, &O_RDONLY | $TAINT0 ) }, undef ); +is( $@, '' ); #13........... }, diff --git a/t/snippets14.t b/t/snippets14.t index 72126a68..207683f9 100644 --- a/t/snippets14.t +++ b/t/snippets14.t @@ -750,7 +750,7 @@ sub next_sibling { params => "def", expect => <<'#10...........', #!/usr/bin/perl -w -use strict; # with -kgb, no break after hash bang +use strict; # with -kgb, no break after hash bang our ( @Changed, $TAP ); # break after isolated 'our' use File::Compare; use Symbol; @@ -773,7 +773,7 @@ print "break before this line\n"; params => "kgb", expect => <<'#11...........', #!/usr/bin/perl -w -use strict; # with -kgb, no break after hash bang +use strict; # with -kgb, no break after hash bang our ( @Changed, $TAP ); # break after isolated 'our' use File::Compare;