]> git.donarmstrong.com Git - perltidy.git/commitdiff
Adjust tolerances to fix some unstable edge cases
authorSteve Hancock <perltidy@users.sourceforge.net>
Mon, 21 Jun 2021 13:03:41 +0000 (06:03 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Mon, 21 Jun 2021 13:03:41 +0000 (06:03 -0700)
lib/Perl/Tidy/Formatter.pm
local-docs/BugLog.pod

index 5989b27056a903cf43528116e55453ac4516e6fa..f076294975601eadc4a9a3d197db155298ec5e29 100644 (file)
@@ -15468,9 +15468,29 @@ sub set_continuation_breaks {
         # necessary for -lp which has a more variable indentation.  At least 3
         # characters have been found to be required.
         # Fixes cases b1059 b1063 b1117.
+
+        # Testing shows that we need a total of 3 extra spaces when -lp is set
+        # for non-lists, and at least 2 spaces when -lp and -xci are set.
+        # The following formulation is a minimal set of values which works.
+        # Fixes cases b1063 b1103 b1134 b1135 b1136 b1138 b1140 b1143 b1144
+        # b1145 b1146 b1147 b1148 b1151 b1152 b1153 b1154 b1156 b1157 b1164
+        # b1165
         $length_tol_boost = 0;
-        if ($rOpts_line_up_parentheses) { $length_tol_boost = 3 }
+        if ($rOpts_line_up_parentheses) {
+
+            if ( $rOpts->{'extended-continuation-indentation'} ) {
+                $length_tol += 2;
+                $length_tol_boost = 1;
+            }
+            else {
+                $length_tol_boost = 3;
+            }
+        }
 
+        # The -xci option alone also needs a slightly larger tol for non-lists
+        elsif ( $rOpts->{'extended-continuation-indentation'} ) {
+               $length_tol_boost = 1;
+        }
         return;
     }
 
@@ -16196,8 +16216,8 @@ sub set_continuation_breaks {
                       $self->excess_line_length( $i_opening_minus, $i );
 
                     my $tol =
-                         $length_tol_boost
-                      && $ris_broken_container->{$type_sequence}
+                      $length_tol_boost
+                      && !$ris_list_by_seqno->{$type_sequence}
                       ? $length_tol + $length_tol_boost
                       : $length_tol;
 
index c9af7cb318b7d68fc925fb4246fdcd2be47b2d4b..198fef78f81ac2988adb0ea58a5f58c134db9881 100644 (file)
@@ -4,6 +4,20 @@
 
 =item B<Adjust tolerances to fix some unstable edge cases>
 
+Testing with random input parameters produced a number of edge cases of
+unstable formatting which were traced to the parameter combinations which
+included -lp and some other unusual settings.
+
+This fixes cases b1103 b1134 b1135 b1136 b1138 b1140 b1143 b1144 b1145 b1146
+b1147 b1148 b1151 b1152 b1153 b1154 b1156 b1157 b1163 b1164 b1165
+
+There are no other known cases of formatting instability at the present time,
+but testing with random input parameters will continue.
+
+21 Jun 2021.
+
+=item B<Adjust tolerances to fix some unstable edge cases>
+
 Testing with random 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
@@ -12,7 +26,7 @@ to fix the problem.
 This fixes cases b1137 b1149 b1150 b1155 b1158 b1159 b1160 b1161 b1166 b1167
 b1168.
 
-19 Jun 2021.
+19 Jun 2021, 4d4970a.
 
 =item B<Added flag -atnl, --add-terminal-newline, see git #58>