From 4d4970a8bdc97839567d51c60d24eec010e06b07 Mon Sep 17 00:00:00 2001 From: Steve Hancock <perltidy@users.sourceforge.net> Date: Sat, 19 Jun 2021 05:56:48 -0700 Subject: [PATCH] Adjust tolerances to fix some unstable edge cases --- lib/Perl/Tidy/Formatter.pm | 14 ++++++++++++++ local-docs/BugLog.pod | 18 +++++++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 9bae006e..7f6a4b33 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -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 &&...) diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index e8a29473..4c353f4a 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -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> -- 2.39.5