From 306546bef31939c3f3d08cb0075e45297c9ed260 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Sun, 21 Nov 2021 06:56:39 -0800 Subject: [PATCH] fix b1259, b1260, instabilities with -bbxi=2 and very short lines --- CHANGES.md | 8 ----- dev-bin/run_convergence_tests.pl.data | 51 +++++++++++++++++++++++++++ lib/Perl/Tidy/Formatter.pm | 12 ++++++- 3 files changed, 62 insertions(+), 9 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index b8d8deb3..b0d7f90c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,14 +8,6 @@ where -lp and -xci flags were not working well together have been fixed, such as happened in issue rt140025. - - A new flag -xlp has been added which can be set to avoid most of the - limitations of the -lp flag regarding side comments, blank lines, and - code blocks. This is off by default to avoid changing existing coding, - so this flag has to be set to turn this feature on. [Documentation still - needs to be written]. It will be included in the next release to CPAN, - but some details regarding how it handles very long lines may change before - the final release to CPAN. This fixes issues git #64 and git #74. - ## 2021 10 29 - No significant bugs have been found since the last release, but several diff --git a/dev-bin/run_convergence_tests.pl.data b/dev-bin/run_convergence_tests.pl.data index b73404ef..9b17b870 100644 --- a/dev-bin/run_convergence_tests.pl.data +++ b/dev-bin/run_convergence_tests.pl.data @@ -8292,6 +8292,57 @@ printf --break-before-all-operators --maximum-line-length=50 +==> b1259.in <== +# S1 + $menubar->Menubutton( + -tearoff=>0, + -text=>'File', + -menuitems=> + [ + [Button=>'Save',-command=>\&save_bookmarks],[Button=>'Quit',-command=>\&exit_program], + ] + )->pack(-side=>'left'); + +# S2 + $menubar->Menubutton( + -tearoff=>0, + -text=>'File', + -menuitems=> + [ + [Button=>'Save',-command=>\&save_bookmarks], + [Button=>'Quit',-command=>\&exit_program], + ] + )->pack(-side=>'left'); + +==> b1259.par <== +--noadd-whitespace +--break-before-square-bracket-and-indent=2 +--break-before-square-bracket=3 +--continuation-indentation=9 +--ignore-old-breakpoints +--maximum-line-length=94 +--variable-maximum-line-length + +==> b1260.in <== +# S1 + my @cmd = + + ( $::cfg_path_diff, split ( / /, $::cfg_args_diff ), $match1, $match2 ) ; +# S2 + my @cmd = + + ( $::cfg_path_diff, split ( / /, $::cfg_args_diff ), $match1, + $match2 ) ; + +==> b1260.par <== +--break-before-paren-and-indent=2 +--break-before-paren=2 +--continuation-indentation=9 +--indent-columns=8 +--maximum-line-length=89 +--space-keyword-paren +--space-terminal-semicolon + ==> b131.in <== unless ( open( SCORE, "+>>$Score_File" ) ) diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 756c9467..2cfa1751 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -18615,10 +18615,20 @@ EOM # Return if this will fit on one line #------------------------------------------------------------------- + # The -bbxi=2 parameters can add an extra hidden level of indentation; + # this needs a tolerance to avoid instability. Fixes b1259, 1260. + my $tol = 0; + if ( $break_before_container_types{$opening_token} + && $container_indentation_options{$opening_token} + && $container_indentation_options{$opening_token} == 2 ) + { + $tol = $rOpts_indent_columns; + } + my $i_opening_minus = $self->find_token_starting_list($i_opening_paren); return unless $self->excess_line_length( $i_opening_minus, $i_closing_paren ) - > 0; + + $tol > 0; #------------------------------------------------------------------- # Now we know that this block spans multiple lines; we have to set -- 2.39.5