]> git.donarmstrong.com Git - perltidy.git/commitdiff
Fix edge case of formatting instability, b1185
authorSteve Hancock <perltidy@users.sourceforge.net>
Sun, 1 Aug 2021 14:44:24 +0000 (07:44 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sun, 1 Aug 2021 14:44:24 +0000 (07:44 -0700)
dev-bin/run_convergence_tests.pl.data
lib/Perl/Tidy/Formatter.pm
local-docs/BugLog.pod

index 134a138aba6517d1222597d9b21c6ab956b5f279..2fe5c8413862505c96f8b7a370dccbcf8f554911 100644 (file)
@@ -6904,6 +6904,33 @@ ok(  (  Win32::GetFullPathName(
 --weld-nested-containers
 --vertical-tightness=2
 
+==> b1185.in <==
+# S1
+          my $visible_items = {
+               map { $_->itemnumber => $_ }
+                 $biblio->items
+                 ->filter_by_visible_in_opac
+                 ( { patron => $patron } )
+                 ->as_list
+          };
+#S2
+          my $visible_items = {
+               map { $_->itemnumber => $_ }
+                 $biblio->items
+                 ->filter_by_visible_in_opac
+                 (       {  patron =>
+                              $patron
+                         }
+               )->as_list
+          };
+
+==> b1185.par <==
+--indent-columns=10
+--line-up-parentheses
+--maximum-line-length=44
+--vertical-tightness=2
+--weld-nested-containers
+
 ==> b120.in <==
 # Same as bug96
 # State 1
index 6b9965bfd852e84bae93d9a3f8c2d3c2bc787089..d2d1bc52a37c24c3811767abb664664274edacc2 100644 (file)
@@ -7548,11 +7548,21 @@ sub setup_new_weld_measurements {
         # breaks.
         $self->[_ris_essential_old_breakpoint_]->{$Kprev} = 1;
 
+        # Avoid measuring from between an opening paren and a previous token
+        # which should stay close to it ... fixes b1185
+        my $token_oo  = $rLL->[$Kouter_opening]->[_TOKEN_];
+        my $type_prev = $rLL->[$Kprev]->[_TYPE_];
+        if (   $Kouter_opening == $Kfirst
+            && $token_oo eq '('
+            && $has_tight_paren{$type_prev} )
+        {
+            $Kref = $Kprev;
+        }
+
         # Back up and count length from a token like '=' or '=>' if -lp
         # is used (this fixes b520)
         # ...or if a break is wanted before there
-        my $type_prev = $rLL->[$Kprev]->[_TYPE_];
-        if (   $rOpts_line_up_parentheses
+        elsif ($rOpts_line_up_parentheses
             || $want_break_before{$type_prev} )
         {
 
@@ -13300,9 +13310,9 @@ sub insert_additional_breaks {
 
     sub in_same_container_i {
 
-        # check to see if tokens at i1 and i2 are in the same container, and not
-        # separated by certain characters: => , ? : || or This is an interface
-        # between the _to_go arrays to the rLL array
+        # Check to see if tokens at i1 and i2 are in the same container, and
+        # not separated by certain characters: => , ? : || or
+        # This is an interface between the _to_go arrays to the rLL array
         my ( $self, $i1, $i2 ) = @_;
 
         # quick check
index 076b3bdbb48ec96109e7b228bcec9f1f445da2c8..dadd9848d10012cfd171fdcf388b1f361981f68d 100644 (file)
@@ -2,6 +2,15 @@
 
 =over 4
 
+=item B<Fix edge case of formatting instability, b1185>.
+
+Testing with random parameters produced a case of welding instability involving
+parameters -wn, -vt=2, -lp and a short maximum line length.
+
+This fixes case b1185.
+
+1 Aug 2021.
+
 =item B<Fix edge case of formatting instability, b1183>.
 
 Testing with random parameters produced a case of welding instability involving