From: Steve Hancock Date: Wed, 1 Dec 2021 02:22:18 +0000 (-0800) Subject: fix instability with combo -lp -iob -vmll -bbx=2 (b1266) X-Git-Tag: 20211029.04~15 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=11e2a819728ea6267b0f9536c4e9e59fc6d97f08;p=perltidy.git fix instability with combo -lp -iob -vmll -bbx=2 (b1266) --- diff --git a/dev-bin/run_convergence_tests.pl.data b/dev-bin/run_convergence_tests.pl.data index 2225dc7e..3f1bc44c 100644 --- a/dev-bin/run_convergence_tests.pl.data +++ b/dev-bin/run_convergence_tests.pl.data @@ -8402,6 +8402,31 @@ function( --maximum-line-length=41 --variable-maximum-line-length +==> b1266.in <== + $self->{SUMMARY} =[ + { + 'descr' => 'Total number of users using the site', + 'value' => commify ($total_users) + } + ]; + + $self->{SUMMARY} = + [ + { 'descr' => 'Total number of users using the site', 'value' => commify ($total_users) } + ]; + +==> b1266.par <== +--break-before-square-bracket=2 +--extended-continuation-indentation +--line-up-parentheses +--ignore-old-breakpoints +--indent-columns=8 +--maximum-line-length=88 +--nowant-right-space='!= | * >= = - &= -= %= .= = != | += >= += >=' +--space-function-paren +--square-bracket-tightness=2 +--variable-maximum-line-length + ==> b131.in <== unless ( open( SCORE, "+>>$Score_File" ) ) diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 2070e97d..8bf39337 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -1479,6 +1479,29 @@ EOM $break_before_container_types{'('} = $_ if $_ && $_ > 0; } + #-------------------------------------------------------------- + # The combination -lp -iob -vmll -bbx=2 can be unstable (b1266) + #-------------------------------------------------------------- + # To avoid instabilities, we will change any -bbx=2 to -bbx=1 (stable). + # NOTE: we could make this more precise by looking at any exclusion + # flags for -lp, and allowing -bbx=2 for excluded types. + if ( $rOpts->{'variable-maximum-line-length'} + && $rOpts->{'ignore-old-breakpoints'} + && $rOpts->{'line-up-parentheses'} ) + { + my @changed; + foreach my $key ( keys %break_before_container_types ) { + if ( $break_before_container_types{$key} == 2 ) { + $break_before_container_types{$key} = 1; + push @changed, $key; + } + } + if (@changed) { + + # could write warning here + } + } + %container_indentation_options = (); foreach my $pair ( [ 'break-before-hash-brace-and-indent', '{' ],