]> git.donarmstrong.com Git - perltidy.git/commitdiff
Restrict -bom at cuddled method calls
authorSteve Hancock <perltidy@users.sourceforge.net>
Sun, 21 Feb 2021 13:58:05 +0000 (05:58 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sun, 21 Feb 2021 13:58:05 +0000 (05:58 -0800)
lib/Perl/Tidy/Formatter.pm
local-docs/BugLog.pod

index 18a568e2fe30068d5d548260963d15eca0fe5031..ec34c960f165b22e51e0843ca1d3b2e8dabd4e04 100644 (file)
@@ -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] );
index eaf81324e010b1b3d2af8efd3d2c1a5fcac2c725..940aa7edf486342b3c7b67760d93356f4d394acd 100644 (file)
@@ -2,6 +2,18 @@
 
 =over 4
 
+=item B<Restrict -bom at cuddled method calls>
+
+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<Add weld rule to avoid conflict between -wn and -bom>
 
 Testing with ramdom input parameters produced states which were oscillating