]> git.donarmstrong.com Git - perltidy.git/commitdiff
Modify tolerance in testing for welds
authorSteve Hancock <perltidy@users.sourceforge.net>
Wed, 10 Feb 2021 02:03:17 +0000 (18:03 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Wed, 10 Feb 2021 02:03:17 +0000 (18:03 -0800)
lib/Perl/Tidy/Formatter.pm
local-docs/BugLog.pod

index 05b2e2d1188c84ef9e72bceecd0fb691098572d7..43ab58db0604aff49e55e7026c69b11ed838b640 100644 (file)
@@ -6857,6 +6857,8 @@ sub weld_nested_containers {
 
         my $iline_oc = $outer_closing->[_LINE_INDEX_];
 
+        my $is_old_weld = ( $iline_oo == $iline_io && $iline_ic == $iline_oc );
+
         if ( !$touch_previous_pair ) {
 
             # If this pair is not adjacent to the previous pair (skipped or
@@ -6962,8 +6964,11 @@ sub weld_nested_containers {
         }
 
         # DO-NOT-WELD RULE 3:
-        # Do not weld if this makes our line too long
-        $do_not_weld ||= $excess_length_to_K->($Kinner_opening) >= 0;
+        # Do not weld if this makes our line too long.
+        # Use a tolerance which depends on if the old tokens were welded
+        # (fixes cases b746 b748 b749 b750 b752 b753 b754 b755 b756 b758 b759)
+        $do_not_weld ||= $excess_length_to_K->($Kinner_opening) >=
+          ( $is_old_weld ? $length_tol : 0 );
 
         # DO-NOT-WELD RULE 4; implemented for git#10:
         # Do not weld an opening -ce brace if the next container is on a single
@@ -14356,8 +14361,8 @@ sub set_continuation_breaks {
         if (   $old_breakpoint_to_go[$i_first_comma]
             && $level_comma == $levels_to_go[0] )
         {
-            my $ibreak      = -1;
-            my $obp_count   = 0;
+            my $ibreak    = -1;
+            my $obp_count = 0;
             for ( my $ii = $i_first_comma - 1 ; $ii >= 0 ; $ii -= 1 ) {
                 if ( $old_breakpoint_to_go[$ii] ) {
                     $obp_count++;
index ea3cb1a611d9f5951c089808c1c83db11da14e19..d0f27066dfad16719f3794fe1b7b432dc298825a 100644 (file)
@@ -2,6 +2,17 @@
 
 =over 4
 
+=item B<Modify tolerance in testing for welds>
+
+Random testing with unusual parameters produced some blinking weld states which
+were fixed by modifying a tolerance used in a line length test.  The following
+cases were fixed with this update:
+
+b746 b748 b749 b750 b752 b753 b754 b755 b756 b758 b759 b771 b772 b773 b774
+b782 b783 b784 b785 b786
+
+9 Feb 2021.
+
 =item B<Modified rule for breaking lines at old commas>
 
 Random testing produced some blinking cases resulting from the treatment of old
@@ -11,7 +22,7 @@ were fixed with this update:
 b064 b065 b068 b210 b747
 
 This change has no effect on scripts with normal parameter values.
-9 Feb 2021.
+9 Feb 2021, 5c23661.
 
 =item B<Restrict references to old line breaks>