From 5e85e135818984b1952cb77d7ad8766a6acbb9b1 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Sat, 25 Sep 2021 14:20:33 -0700 Subject: [PATCH] fix issue b1210, very rare instability with -vmll --- dev-bin/run_convergence_tests.pl.data | 23 +++++++++++++++++++++++ lib/Perl/Tidy/Formatter.pm | 19 +++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/dev-bin/run_convergence_tests.pl.data b/dev-bin/run_convergence_tests.pl.data index 16f538f3..235e5570 100644 --- a/dev-bin/run_convergence_tests.pl.data +++ b/dev-bin/run_convergence_tests.pl.data @@ -7433,6 +7433,29 @@ $bc[ --vertical-tightness=1 --weld-nested-containers +==> b1210.in <== +# S1 +@mo = ( Jan, Feb, Mar, Apr, + May, Jun, Jul, Aug, + Sep, Oct, Nov, Dec +); + +# S2 +@mo = + ( Jan, Feb, Mar, Apr, + May, Jun, + Jul, Aug, Sep, Oct, Nov, Dec + ); + + +==> b1210.par <== +--break-before-paren=1 +--continuation-indentation=9 +--indent-columns=7 +--line-up-parentheses +--maximum-line-length=34 +--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 177df1f1..fbab11a9 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -18213,6 +18213,25 @@ EOM # Number of free columns across the page width for laying out tables my $columns = table_columns_available($i_first_comma); + # Patch for b1210 when -vmll is set. If we are unable to break after + # an opening paren, then the maximum line length for the first line + # will be less than the later lines. So we use the minimum possible. + if ( $rOpts_variable_maximum_line_length + && $tokens_to_go[$i_opening_paren] eq '(' + && @i_term_begin + && !$old_breakpoint_to_go[$i_opening_paren] ) + { + my $ib = $i_term_begin[0]; + my $type = $types_to_go[$ib]; + + # So far, the only known instance of this problem is when + # a bareword follows an opening paren with -vmll + if ( $type eq 'w' ) { + my $columns2 = table_columns_available($i_opening_paren); + $columns = min( $columns, $columns2 ); + } + } + # Estimated maximum number of fields which fit this space # This will be our first guess my $number_of_fields_max = -- 2.39.5