]> git.donarmstrong.com Git - perltidy.git/commitdiff
Adjust tolerances to fix some unstable edge cases
authorSteve Hancock <perltidy@users.sourceforge.net>
Sat, 19 Jun 2021 12:56:48 +0000 (05:56 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sat, 19 Jun 2021 12:56:48 +0000 (05:56 -0700)
lib/Perl/Tidy/Formatter.pm
local-docs/BugLog.pod

index 9bae006e78be40721f5bceffd66afb115222ea2b..7f6a4b3310c502185212ce6365b8d1b8a6da14d2 100644 (file)
@@ -15751,6 +15751,8 @@ sub set_continuation_breaks {
         my $rLL                  = $self->[_rLL_];
         my $ris_list_by_seqno    = $self->[_ris_list_by_seqno_];
         my $ris_broken_container = $self->[_ris_broken_container_];
+        my $rbreak_before_container_by_seqno =
+          $self->[_rbreak_before_container_by_seqno_];
 
         $starting_depth = $nesting_depth_to_go[0];
 
@@ -16199,6 +16201,18 @@ sub set_continuation_breaks {
                       ? $length_tol + $length_tol_boost
                       : $length_tol;
 
+                    # Patch to avoid blinking with -bbxi=2 and -cab=2
+                    # in which variations in -ci cause unstable formatting
+                    # in edge cases. We just always add one ci level so that
+                    # the formatting is independent of the -BBX results.
+                    # Fixes cases b1137 b1149 b1150 b1155 b1158 b1159 b1160
+                    # b1161 b1166 b1167 b1168
+                    if (  !$ci_levels_to_go[$i_opening]
+                        && $rbreak_before_container_by_seqno->{$type_sequence} )
+                    {
+                        $tol += $rOpts->{'continuation-indentation'};
+                    }
+
                     $is_long_term = $excess + $tol > 0;
 
                 } ## end if ( !$is_long_term &&...)
index e8a29473c18ea6b2917f07ce756054406e3886b7..4c353f4aaf0aec3c1e175fe2d057f6d9bfed203a 100644 (file)
@@ -2,6 +2,18 @@
 
 =over 4
 
+=item B<Adjust tolerances to fix some unstable edge cases>
+
+Testing with randim input parameters produced a number of edge cases of
+unstable formatting which were traced to the parameter combinations which
+included -bbxi=2 and -cab=2.  A small adjustment to length tolerances was made
+to fix the problem.
+
+This fixes cases b1137 b1149 b1150 b1155 b1158 b1159 b1160 b1161 b1166 b1167
+b1168.
+
+19 Jun 2021.
+
 =item B<Added flag -atnl, --add-terminal-newline, see git #58>
 
 This flag, which is enabled by default, allows perltidy to terminate the last
@@ -15,7 +27,7 @@ use on a command line.
 
 This update also removes the description of the obsolete --check-syntax flag from the man pages and help text.
 
-18 Jun 2021.
+18 Jun 2021, 6f83170.
 
 =item B<Allow --delete-side-comments to work with -nanl>
 
@@ -28,7 +40,7 @@ deleted, for example:
 The same issue was happening for --delete-closing-side comments.
 This has been fixed.
 
-18 Jun 2021.
+18 Jun 2021, dbfd802.
 
 =item B<Update welding rule to avoid unstable states>
 
@@ -54,7 +66,7 @@ and the following code
 
 This update fixes the problem, case b1162.
 
-18 Jun 2021.
+18 Jun 2021, 76873ea.
 
 =item B<Convert some weld sub calls to hash lookups>