]> git.donarmstrong.com Git - perltidy.git/commitdiff
Fix rare problem involving interaction of -olbn=n and -wn flags
authorSteve Hancock <perltidy@users.sourceforge.net>
Sun, 7 Feb 2021 01:57:49 +0000 (17:57 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sun, 7 Feb 2021 01:57:49 +0000 (17:57 -0800)
lib/Perl/Tidy/Formatter.pm
local-docs/BugLog.pod

index be081297ed205f58f4e095455304d9572be66ca1..95d112827688779e0295ec9869e9916f32fb3f70 100644 (file)
@@ -7387,6 +7387,7 @@ sub mark_short_nested_blocks {
     my $K_closing_container = $self->[_K_closing_container_];
     my $rbreak_container    = $self->[_rbreak_container_];
     my $rshort_nested       = $self->[_rshort_nested_];
+    my $ris_welded_seqno    = $self->[_ris_welded_seqno_];
     my $rlines              = $self->[_rlines_];
 
     # Variables needed for estimating line lengths
@@ -7436,6 +7437,12 @@ sub mark_short_nested_blocks {
             Fault("sequence = $type_sequence not defined at K=$KK");
         }
 
+        # Patch: do not mark short blocks with welds.
+        # In some cases blinkers can form (case b690).
+        if ( $ris_welded_seqno->{$type_sequence} ) {
+            next;
+        }
+
         # We are just looking at code blocks
         my $token = $rtoken_vars->[_TOKEN_];
         my $type  = $rtoken_vars->[_TYPE_];
index 25832316b61f18c7683df59335a390f1cc33eb5b..23153c523cccbe7d651acfe83da5febf2800ca9e 100644 (file)
@@ -2,6 +2,18 @@
 
 =over 4
 
+=item B<Fix rare problem involving interaction of -olbn=n and -wn flags>
+
+Random testing revealed a rare alternating state which could occur when both
+flags --one-line-block-nesting=n and --weld-nested-containers are set, and the
+maximum line length is set very low.  The problem was fixed by ignoring the
+first flag at welded tokens.  This should not have any effect on scripts with
+realistic parameter values.
+
+The following case was fixed with this update: b690.
+
+6 Feb 2021.
+
 =item B<add rule to avoid welding at some barewords>
 
 A rule was added to prevent certain rare blinking states involving welding.
@@ -10,7 +22,7 @@ unknown, a weld will be avoided.
 
 The following cases were fixed with this update: b611 b626.
 
-6 Feb 2021.
+6 Feb 2021, 5083ab9.
 
 =item B<further simplify -bbxi=n implementation>