]> git.donarmstrong.com Git - perltidy.git/commitdiff
fix b1487, b1488
authorSteve Hancock <perltidy@users.sourceforge.net>
Sun, 15 Sep 2024 13:32:18 +0000 (06:32 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sun, 15 Sep 2024 13:32:18 +0000 (06:32 -0700)
bin/perltidy
dev-bin/run_convergence_tests.pl.data
dev-bin/run_convergence_tests.pl.expect
lib/Perl/Tidy/Formatter.pm

index ab0b8ec10dc122d567e40e3596ca8b2812acc921..c15f98d21896e54d0aad44e8b772eb036f38e601 100755 (executable)
@@ -3939,7 +3939,7 @@ The parameter B<--want-trailing-commas=s>, or B<-wtc=s>, defines a preferred sty
 
   s=0 : no list should have a trailing comma
   s=1 or * : every list should have a trailing comma
-  s=m a multi-line list should have a trailing commas
+  s=m a multi-line list should have a trailing comma
   s=b trailing commas should be 'bare' (comma followed by newline)
   s=h lists of key=>value pairs, with about one one '=>' and one ',' per line,
       with a bare trailing comma
index a2a0fde9e6e14f4702ce317d8c1dd4c8b40b63e1..e65f53daa9977c33f23074da3b775bedb9ee75cd 100644 (file)
@@ -12264,6 +12264,37 @@ use
 --noadd-whitespace
 --qw-as-function
 
+==> b1487.in <==
+use Net::Domain qw(hostname domainname
+                   hostdomain);
+use Net::Domain qw(
+                    hostname
+                    domainname
+                    hostdomain
+);
+
+==> b1487.par <==
+--maximum-line-length=41
+--continuation-indentation=7
+--line-up-parentheses
+--noadd-whitespace
+--qw-as-function
+
+==> b1488.in <==
+use vars qw(
+             $VERSION @ISA
+             @EXPORT_OK %EXPORT_TAGS
+);
+use vars qw($VERSION @ISA
+            @EXPORT_OK %EXPORT_TAGS);
+
+==> b1488.par <==
+--maximum-line-length=48
+--continuation-indentation=6
+--noadd-whitespace
+--extended-line-up-parentheses
+--qw-as-function
+
 ==> b156.in <==
 # State 1
 {
index cdc9f126148f49c25cb4df4bbf03d297311525f0..a73b4d6d8606fda045b63dc6856758e6c8eaeec0 100644 (file)
@@ -8309,6 +8309,23 @@ use UnixODBC
   :all
   );
 
+==> b1487 <==
+use Net::Domain qw(hostname domainname
+       hostdomain);
+use Net::Domain qw(
+       hostname
+       domainname
+       hostdomain
+);
+
+==> b1488 <==
+use vars qw(
+      $VERSION @ISA
+      @EXPORT_OK %EXPORT_TAGS
+);
+use vars qw($VERSION @ISA
+      @EXPORT_OK %EXPORT_TAGS);
+
 ==> b156 <==
 # State 1
 {
index 0863c28da1c83ae6d2c291984031c12ef7933974..49810c48b358f6943c1e29f5afb1f29a111a671a 100644 (file)
@@ -6753,6 +6753,15 @@ EOM
             return;
         }
 
+        # The combination -naws -lp can currently be unstable for multi-line qw
+        # (b1487, b1488).
+        if (  !$rOpts_add_whitespace
+            && $rOpts_line_up_parentheses
+            && ( !$opening || !$closing ) )
+        {
+            return;
+        }
+
         #---------------------------------------------------------------------
         # This is the point of no return if the transformation has not started
         #---------------------------------------------------------------------
@@ -14202,16 +14211,23 @@ sub match_trailing_comma_rule {
         $has_multiline_commas = $line_diff_commas > 0;
     }
 
-    # To avoid instability in edge cases, when adding commas we uses the
-    # multiline_commas definition, but when deleting we use multiline
-    # containers.  This fixes b1384, b1396, b1397, b1398, b1400.
-    # Added fat_comma_count to handle one-line with key=>value, git143
+    # To avoid instability in edge cases, we must make it somewhat easier
+    # to delete commas than to add commas. The following prescription
+    # fixes b1384, b1396, b1397, b1398, b1400.
     my $is_multiline =
         $if_add
-      ? $has_multiline_commas || $has_multiline_containers && $fat_comma_count
+      ? $has_multiline_commas
       : $has_multiline_containers;
 
-    my $is_bare_multiline_comma = $is_multiline && $KK == $Kfirst;
+    # Old coding for bare comma, very stable:
+    #   my $is_bare_multiline_comma = $KK == $Kfirst && $is_multiline;
+
+    # Testing new coding for bare comma adds fat_comma_count to handle adding
+    # comma to one-line with key=>value, git143
+    my $is_bare_multiline_comma = $KK == $Kfirst;
+    if ($if_add) {
+        $is_bare_multiline_comma &&= $has_multiline_commas || $fat_comma_count;
+    }
 
     my $match;