From: Steve Hancock Date: Sun, 7 Feb 2021 01:57:49 +0000 (-0800) Subject: Fix rare problem involving interaction of -olbn=n and -wn flags X-Git-Tag: 20210402~59 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=3e969305373eefc69b95790a65a8ef46f855ed5d;p=perltidy.git Fix rare problem involving interaction of -olbn=n and -wn flags --- diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index be081297..95d11282 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -7387,6 +7387,7 @@ sub mark_short_nested_blocks { my $K_closing_container = $self->[_K_closing_container_]; my $rbreak_container = $self->[_rbreak_container_]; my $rshort_nested = $self->[_rshort_nested_]; + my $ris_welded_seqno = $self->[_ris_welded_seqno_]; my $rlines = $self->[_rlines_]; # Variables needed for estimating line lengths @@ -7436,6 +7437,12 @@ sub mark_short_nested_blocks { Fault("sequence = $type_sequence not defined at K=$KK"); } + # Patch: do not mark short blocks with welds. + # In some cases blinkers can form (case b690). + if ( $ris_welded_seqno->{$type_sequence} ) { + next; + } + # We are just looking at code blocks my $token = $rtoken_vars->[_TOKEN_]; my $type = $rtoken_vars->[_TYPE_]; diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index 25832316..23153c52 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -2,6 +2,18 @@ =over 4 +=item B + +Random testing revealed a rare alternating state which could occur when both +flags --one-line-block-nesting=n and --weld-nested-containers are set, and the +maximum line length is set very low. The problem was fixed by ignoring the +first flag at welded tokens. This should not have any effect on scripts with +realistic parameter values. + +The following case was fixed with this update: b690. + +6 Feb 2021. + =item B A rule was added to prevent certain rare blinking states involving welding. @@ -10,7 +22,7 @@ unknown, a weld will be avoided. The following cases were fixed with this update: b611 b626. -6 Feb 2021. +6 Feb 2021, 5083ab9. =item B