From: Steve Hancock Date: Sun, 21 Feb 2021 13:58:05 +0000 (-0800) Subject: Restrict -bom at cuddled method calls X-Git-Tag: 20210402~38 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=28114e962039332e10dc8f57d1cb8df23cf66a86;p=perltidy.git Restrict -bom at cuddled method calls --- diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 18a568e2..ec34c960 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -14601,6 +14601,8 @@ sub set_continuation_breaks { my $rOpts_break_at_old_ternary_breakpoints = $rOpts->{'break-at-old-ternary-breakpoints'}; + my $ris_broken_container = $self->[_ris_broken_container_]; + $starting_depth = $nesting_depth_to_go[0]; $block_type = ' '; @@ -14772,14 +14774,24 @@ sub set_continuation_breaks { # look for old lines with leading ')->' or ') ->' # and, when found, force a break before the # opening paren and after the previous closing paren. - if ( - $i_line_start >= 0 - && $types_to_go[$i_line_start] eq '}' - && ( $i == $i_line_start + 1 + my $ok = ( + $i_line_start >= 0 + && $types_to_go[$i_line_start] eq '}' + && ( $i == $i_line_start + 1 || $i == $i_line_start + 2 && $types_to_go[ $i - 1 ] eq 'b' ) - ) - { + ); + + # Patch to avoid blinkes: but do not do this unless + # line difference is > 1 (see case b977) + if ($ok) { + my $seqno = $type_sequence_to_go[$i_line_start]; + if ( $ris_broken_container->{$seqno} <= 1 ) { + $ok = 0; + } + } + + if ($ok) { $self->set_forced_breakpoint( $i_line_start - 1 ); $self->set_forced_breakpoint( $mate_index_to_go[$i_line_start] ); diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index eaf81324..940aa7ed 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -2,6 +2,18 @@ =over 4 +=item B + +The -bom flag tries to keep old breakpoints at lines beginning with '->' and +also with some lines beginning with ')->'. These latter lines can lead to +blinking states in cases where the opening paren is on the previous line. To +fix this, a restriction was added that the line difference between the opening +and closing parens should be more than 1. + +This fixes case b977. + +21 Feb 2021 + =item B Testing with ramdom input parameters produced states which were oscillating