From 245e1cb8fea81cc45b93c57ac3cc380ff3e539be Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Fri, 3 Dec 2021 09:01:35 -0800 Subject: [PATCH] fix issue with -lp -vmll -ci<2 (b1267) --- dev-bin/run_convergence_tests.pl.data | 25 +++++++++++++++++++++++++ lib/Perl/Tidy/Formatter.pm | 16 +++++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/dev-bin/run_convergence_tests.pl.data b/dev-bin/run_convergence_tests.pl.data index 3f1bc44c..b1e48b43 100644 --- a/dev-bin/run_convergence_tests.pl.data +++ b/dev-bin/run_convergence_tests.pl.data @@ -8427,6 +8427,31 @@ function( --square-bracket-tightness=2 --variable-maximum-line-length +==> b1267.in <== +# S1 + foreach ( + grep + ( $self->{_unique_nodes}->{$_} + > 1, + keys + %{ $self->{_unique_nodes} } ) + ) +# S2 + foreach ( + grep + ( $self->{_unique_nodes}->{$_} + > 1, + keys %{ + $self->{_unique_nodes} + } ) + ) + +==> b1267.par <== +--continuation-indentation=0 +--line-up-parentheses +--maximum-line-length=30 +--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 8bf39337..04aada48 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -1482,6 +1482,7 @@ EOM #-------------------------------------------------------------- # The combination -lp -iob -vmll -bbx=2 can be unstable (b1266) #-------------------------------------------------------------- + # The -vmll and -lp parameters do not really work well together. # 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. @@ -1498,10 +1499,23 @@ EOM } if (@changed) { - # could write warning here + # we could write a warning here } } + #----------------------------------------------------------- + # The combination -lp -vmll can be unstable if -ci<2 (b1267) + #----------------------------------------------------------- + # The -vmll and -lp parameters do not really work well together. + # This is a very crude fix for an unusual parameter combination. + if ( $rOpts->{'variable-maximum-line-length'} + && $rOpts->{'line-up-parentheses'} + && $rOpts->{'continuation-indentation'} < 2 ) + { + $rOpts->{'continuation-indentation'} = 2; + ##Warn("Increased -ci=n to n=2 for stability with -lp and -vmll\n"); + } + %container_indentation_options = (); foreach my $pair ( [ 'break-before-hash-brace-and-indent', '{' ], -- 2.39.5