From: Steve Hancock Date: Mon, 21 Jun 2021 13:03:41 +0000 (-0700) Subject: Adjust tolerances to fix some unstable edge cases X-Git-Tag: 20210625~1 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=1b682fdf5565aa56820314705f7b60268c337c9d;p=perltidy.git Adjust tolerances to fix some unstable edge cases --- diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 5989b270..f0762949 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -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; diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index c9af7cb3..198fef78 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -4,6 +4,20 @@ =item B +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 + 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