]> git.donarmstrong.com Git - perltidy.git/commitdiff
reset -bbxi=2 to -bbxi=0 if -lp is set to avoid blinking states
authorSteve Hancock <perltidy@users.sourceforge.net>
Thu, 4 Feb 2021 14:22:32 +0000 (06:22 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Thu, 4 Feb 2021 14:22:32 +0000 (06:22 -0800)
lib/Perl/Tidy/Formatter.pm
local-docs/BugLog.pod

index 51392c35ccdd122d6cb2c2efd9946366de9c9e11..0f82a51b2f0acf8ff734d3e623ec086bcca8c88e 100644 (file)
@@ -1259,22 +1259,20 @@ EOM
     }
 
     %container_indentation_options = ();
-    for ( $rOpts->{'break-before-hash-brace-and-indent'} ) {
-        my $tok = '{';
-        if ( defined($_) && $_ > 0 && $break_before_container_types{$tok} ) {
-            $container_indentation_options{$tok} = $_;
-        }
-    }
-    for ( $rOpts->{'break-before-square-bracket-and-indent'} ) {
-        my $tok = '[';
-        if ( defined($_) && $_ > 0 && $break_before_container_types{$tok} ) {
-            $container_indentation_options{$tok} = $_;
-        }
-    }
-    for ( $rOpts->{'break-before-paren-and-indent'} ) {
-        my $tok = '(';
-        if ( defined($_) && $_ > 0 && $break_before_container_types{$tok} ) {
-            $container_indentation_options{$tok} = $_;
+    foreach my $pair (
+        [ 'break-before-hash-brace-and-indent',     '{' ],
+        [ 'break-before-square-bracket-and-indent', '[' ],
+        [ 'break-before-paren-and-indent',          '(' ],
+      )
+    {
+        my ( $key, $tok ) = @{$pair};
+        my $opt = $rOpts->{$key};
+        if ( defined($opt) && $opt > 0 && $break_before_container_types{$tok} )
+        {
+
+            # -lp is not compatable with opt=3, silently set to opt=0
+            if ( $rOpts->{'line-up-parentheses'} && $opt == 2 ) { $opt = 0 }
+            $container_indentation_options{$tok} = $opt;
         }
     }
 
@@ -7655,8 +7653,12 @@ sub break_before_list_opening_containers {
 
         my $KK = $K_opening_container->{$seqno};
 
+        my $is_list  = $self->is_list_by_seqno($seqno);
+        my $has_list = $rhas_broken_container->{$seqno};
+
         # This must be a list (this will exclude all code blocks)
-        next unless $self->is_list_by_seqno($seqno);
+        # or contain a list
+        next unless ( $is_list || $has_list );
 
         # Only for types of container tokens with a non-default break option
         my $token        = $rLL->[$KK]->[_TOKEN_];
@@ -7693,7 +7695,7 @@ sub break_before_list_opening_containers {
         #  - this list contains a broken container, or
         #  - this list is contained in a broken list
         elsif ( $break_option == 2 ) {
-            my $ok_to_break = $rhas_broken_container->{$seqno};
+            my $ok_to_break = $has_list;
             if ( !$ok_to_break ) {
                 my $parent = $rparent_of_seqno->{$seqno};
                 $ok_to_break = $self->is_list_by_seqno($parent);
index d59433003d93defb2f6504fcd23ceff940d0f265..8f48d62f7e7e5f058fa727bfdf877e9999f49563 100644 (file)
@@ -2,6 +2,21 @@
 
 =over 4
 
+=item B<reset -bbxi=2 to -bbxi=0 if -lp is set to avoid blinking states>
+
+The options of the form bbxi=2, such as break-before-paren-and-indent=2, have
+been found to cause blinking states if the -lp flag is set. Both of these
+options are fairly rare. To correct this the -bbxi=2 flag is now reset to
+-bbxi=0 if the -lp flag is set.  Note that -bbxi=2 and -bbxi=0 give the same
+formatting result with the common setting -ci=4 and -i=4.
+
+The following cases were fixed with this update:
+
+b396 b397 b398 b429 b435 b457 b502 b503 b504 b505 b538 b540 b542 b617 b618 b619
+b620 b621
+
+3 Feb 2021.
+
 =item B<rewrite sub break_before_list_opening_containers>
 
 sub break_before_list_opening_containers was rewritten to reduce the chance