]> git.donarmstrong.com Git - perltidy.git/commitdiff
Add rule to avoid conflict between -wn and -bom
authorSteve Hancock <perltidy@users.sourceforge.net>
Sat, 20 Feb 2021 14:51:05 +0000 (06:51 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sat, 20 Feb 2021 14:51:05 +0000 (06:51 -0800)
lib/Perl/Tidy/Formatter.pm
local-docs/BugLog.pod

index 066e87a7955bcb7cff41d5d1a4760ad8fde57670..18a568e2fe30068d5d548260963d15eca0fe5031 100644 (file)
@@ -1058,7 +1058,6 @@ sub check_options {
         $rOpts->{'continuation-indentation'} = $rOpts->{'indent-columns'};
     }
 
-
     if ( $rOpts->{'line-up-parentheses'} ) {
 
         if (   $rOpts->{'indent-only'}
@@ -6778,6 +6777,9 @@ sub weld_nested_containers {
     # Return unless there are nested pairs to weld
     return unless defined($rnested_pairs) && @{$rnested_pairs};
 
+    my $rOpts_break_at_old_method_breakpoints =
+      $rOpts->{'break-at-old-method-breakpoints'};
+
     # This array will hold the sequence numbers of the tokens to be welded.
     my @welds;
 
@@ -7068,6 +7070,25 @@ sub weld_nested_containers {
             }
         }
 
+        # DO-NOT-WELD RULE 7: Do not weld if this conflicts with -bom
+        # (case b973)
+        if (  !$do_not_weld
+            && $rOpts_break_at_old_method_breakpoints
+            && $iline_io > $iline_oo )
+        {
+
+            foreach my $iline ( $iline_oo + 1 .. $iline_io ) {
+                my $rK_range = $rlines->[$iline]->{_rK_range};
+                next unless defined($rK_range);
+                my ( $Kfirst, $Klast ) = @{$rK_range};
+                next unless defined($Kfirst);
+                if ( $rLL->[$Kfirst]->[_TYPE_] eq '->' ) {
+                    $do_not_weld = 1;
+                    last;
+                }
+            }
+        }
+
         if ($do_not_weld) {
 
             # After neglecting a pair, we start measuring from start of point io
index bc611439ce5e3acbc7521f744787bd4be3507a01..eaf81324e010b1b3d2af8efd3d2c1a5fcac2c725 100644 (file)
@@ -2,6 +2,16 @@
 
 =over 4
 
+=item B<Add weld rule to avoid conflict between -wn and -bom>
+
+Testing with ramdom input parameters produced states which were oscillating
+because of a conflict between the -wn and -bom parameters.  The problem
+was resolved by giving the -bom parameter priority over -wn.
+
+These cases are fixed with this update: b966 b973
+
+20 Feb 2021.
+
 =item B<Limit the value of -ci=n to that of -i=n when -xci is set>
 
 Testing with random input parameters produced a number of oscillating states
@@ -13,7 +23,7 @@ because a value of -ci greater than -i would not normally be used in practice.
 These cases are fixed with this update:
 b707 b770 b912 b920 b930 b933 b939 b940 b941 b942 b978 b974 b979 b980 b981
 
-20 Feb 2021.
+20 Feb 2021, c16c5ee.
 
 =item B<Modify length tolerance for welding to qw lists>
 
@@ -23,7 +33,7 @@ This was fixed by adding a small tolerance to line length tests.
 
 This fixes cases b654 b655 b943 b944 b967 b968 b969 b970.
 
-19 Feb 2021.
+19 Feb 2021, 0baafc8.
 
 =item B<Modify space rule between binary plus or minus and a bareword>