]> git.donarmstrong.com Git - perltidy.git/commitdiff
fixed some two line alignments
authorSteve Hancock <perltidy@users.sourceforge.net>
Sun, 13 Oct 2019 13:48:46 +0000 (06:48 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sun, 13 Oct 2019 13:48:46 +0000 (06:48 -0700)
CHANGES.md
lib/Perl/Tidy/VerticalAligner.pm
t/snippets/align21.in
t/snippets/expect/align21.def
t/snippets/expect/kgb3.def
t/snippets/expect/kgb3.kgb
t/snippets/packing_list.txt
t/snippets13.t
t/snippets14.t

index 1c877c6e2191e46e29503564743b3d338a5c6dc8..ed17d7c6c4238e64b0aa9427ea0c58db59f13e4b 100644 (file)
@@ -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,
         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
 
index 41795d0d7a837a6aef94d711338907f363f9b467..bad2999f787dd86c899c25ef33bdac155de8ca97 100644 (file)
@@ -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++ ) {
index 216bed1947a62be220c4d0819a85ab66a2669bd5..377037976f6fa653d1e33b538cd5eaa915028110 100644 (file)
@@ -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( $@, '' );
index 216bed1947a62be220c4d0819a85ab66a2669bd5..be44c4f355d73164b2ccd76c74bb2cb9e020fca8 100644 (file)
@@ -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( $@,                                                    '' );
index 0f805444ee63b95cba475500582d76f81c1fb333..5cdbe88c55c5ce22a5143d609e7e7bee9d326b43 100644 (file)
@@ -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;
index 61e1c6d567efc8dc6570dbd77e63c367c52c0257..159b0c265e635dc99b3cb753c743847a578ce16f 100644 (file)
@@ -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;
index e9032c0ace6598b453af283cce0da65d127b8d3c..5076cc6d06d9c85fb57ff8c7aa8d460270252a9f 100644 (file)
 ../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
 ../snippets9.t rt98902.def
 ../snippets9.t rt98902.rt98902
 ../snippets9.t rt99961.def
-../snippets16.t        git10.def
-../snippets16.t        git10.git10
index b575f1030f41258e67bf9092ebd9e750ff8ac1be..8d7bccdc4523e92a5a12cbb35a7cdfc5f31e4367 100644 (file)
@@ -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...........
         },
 
index 72126a68099228063c5e1096b1eb8c4e971a5238..207683f9760946361d93ca431c81a31467fc197f 100644 (file)
@@ -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;