From 5c793a12e31cbdddcdae0b39de5e32c667366277 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Fri, 15 Jan 2021 07:55:59 -0800 Subject: [PATCH] Fixed blinker related to large -ci, short line length and -bbsbi=2 -bbsb=1 --- lib/Perl/Tidy/Formatter.pm | 8 ++++++-- local-docs/BugLog.pod | 28 ++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index a5339bfd..5270f5fa 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -7557,8 +7557,12 @@ sub adjust_container_indentation { # This is only for list containers next unless $self->is_list_by_seqno($seqno); - # and only for broken lists - next unless $ris_broken_container->{$seqno}; + # and only for broken lists. + # Require container to span 3 or more line to avoid blinkers, + # so line difference must be 2 or more. + next + if ( $ris_broken_container->{$seqno} + && $ris_broken_container->{$seqno} <= 1 ); # NOTE: We are adjusting indentation of the opening container. The # closing container will normally follow the indentation of the opening diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index adacec39..e60c435a 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -2,6 +2,34 @@ =over 4 +=item B + +A blinking state was discovered in testing between the following two states + + my$table= + [[1,2,3],[2,4,6],[3,6,9], + ]; + + my$table= + [[1,2,3],[2,4,6],[3,6,9],]; + +with these parameters + + --continuation-indentation=5 + --maximum-line-length=31 + --break-before-square-bracket-and-indent=2 + --break-before-square-bracket=1 + --noadd-whitespace + +The problem was found to be caused by the -bbsb parameters causing +the indentation level of the first square bracket to change depending +upon whether the term was broken on input or not. Two fixes would correct +this. One is to turn off the option if the -ci=n value exceeds the -i=n +value. The other is to require a broken container to span at least three +lines before turning this option on. The latter option was made +to sub 'adjust_container_indentation'. With this change the snippet remains +stable at the second state above. Fixed 14 Jan 2021. + =item B In random testing with convergence a 'blinker' (oscillating states) was found -- 2.39.5