]> git.donarmstrong.com Git - perltidy.git/commitdiff
Fix problems with combinations of -iob -lp
authorSteve Hancock <perltidy@users.sourceforge.net>
Sat, 27 Mar 2021 23:37:34 +0000 (16:37 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sat, 27 Mar 2021 23:37:34 +0000 (16:37 -0700)
lib/Perl/Tidy/Formatter.pm
local-docs/BugLog.pod

index d3b96de41d9712c0ca1bfd1ddd27c089ae4afcad..5ad2119696874a7d8814a8fbc288542712c424f2 100644 (file)
@@ -6435,9 +6435,12 @@ sub resync_lines_and_tokens {
     $file_writer_object->setup_convergence_test( \@Klast_valign_code );
 
     # Mark essential old breakpoints if combination -iob -lp is used.  These
-    # two options do not work well together, but we can avoid turning one off by
-    # ignoring -iob at certain essential line breaks.  Fixes b1021.
+    # two options do not work well together, but we can avoid turning -iob off
+    # by ignoring -iob at certain essential line breaks.
+    # Fixes cases b1021 b1023 b1034 b1048 b1049 b1050 b1056 b1058
     if ( $rOpts_ignore_old_breakpoints && $rOpts_line_up_parentheses ) {
+        my %is_assignment_or_fat_comma = %is_assignment;
+        $is_assignment_or_fat_comma{'=>'} = 1;
         my $ris_essential_old_breakpoint =
           $self->[_ris_essential_old_breakpoint_];
         my $iline = -1;
@@ -6451,14 +6454,14 @@ sub resync_lines_and_tokens {
             }
             my ( $Kfirst_prev, $Klast_prev ) = ( $Kfirst, $Klast );
             ( $Kfirst, $Klast ) = @{ $line_of_tokens->{_rK_range} };
+
             next unless defined($Klast_prev);
-            next unless defined($Klast);
-            my $level_first = $rLL->[$Kfirst]->[_LEVEL_];
-            my $level_last  = $rLL->[$Klast]->[_LEVEL_];
-            my $type_last   = $rLL->[$Klast]->[_TOKEN_];
+            next unless defined($Kfirst);
+            my $type_last  = $rLL->[$Klast_prev]->[_TOKEN_];
+            my $type_first = $rLL->[$Kfirst]->[_TOKEN_];
             next
-              unless ( $level_last > $level_first
-                || $is_closing_type{$type_last} );
+              unless ( $is_assignment_or_fat_comma{$type_last}
+                || $is_assignment_or_fat_comma{$type_first} );
             $ris_essential_old_breakpoint->{$Klast_prev} = 1;
         }
     }
index 516392a664d87d814a16a2c617c999bc1ec54b16..9ce8707121b1676e317791893ceb8e5c9ccedd81 100644 (file)
@@ -2,12 +2,25 @@
 
 =over 4
 
+=item B<Fix problems with combinations of -iob -lp>
+
+This is an correction to the update of 13 Mar 2021, 71adc77.  Random testing
+produced several additional problems with convergence involving the combination
+-iob -lp.  This update fixes the problem by overriding -iob at some breakpoins
+which are essential to the -lp parameter.
+
+This update fixes these old cases: b1021 b1023
+
+and these new cases: b1034 b1048 b1049 b1050 b1056 b1058
+
+27 Mar 2021
+
 =item B<Add flag -lpxl=s to provide control over -lp formatting>
 
 The flag -lpxl=s provides control over which containers get -lp formatting.
 A shortcut flag -lfp is also added for limiting -lp to simple function calls.
 
-Updated 25 Mar 2021.
+Updated 25 Mar 2021, bfc00fp.
 
 
 =item B<Fix error message for multiple conflicting specifications in -wnxl>