From: Steve Hancock Date: Thu, 4 Feb 2021 14:22:32 +0000 (-0800) Subject: reset -bbxi=2 to -bbxi=0 if -lp is set to avoid blinking states X-Git-Tag: 20210402~62 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=67ab0ef46e818c406e84acd852b59e985fa54547;p=perltidy.git reset -bbxi=2 to -bbxi=0 if -lp is set to avoid blinking states --- diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 51392c35..0f82a51b 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -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); diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index d5943300..8f48d62f 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -2,6 +2,21 @@ =over 4 +=item B + +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 sub break_before_list_opening_containers was rewritten to reduce the chance