From: Steve Hancock Date: Wed, 6 Oct 2021 19:04:20 +0000 (-0700) Subject: fix issue b1213 X-Git-Tag: 20211029~33 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=fe23e2268472f8ec7eb96a81043f17afe52ec05b;p=perltidy.git fix issue b1213 --- diff --git a/dev-bin/run_convergence_tests.pl.data b/dev-bin/run_convergence_tests.pl.data index 983aa5dc..8722f6df 100644 --- a/dev-bin/run_convergence_tests.pl.data +++ b/dev-bin/run_convergence_tests.pl.data @@ -7480,6 +7480,25 @@ $bc[ --variable-maximum-line-length --weld-nested-containers +==> b1213.in <== +# S1 + @NNVN_w1 = ( Perl, + Practical, + Precocious + ); +# S2 + @NNVN_w1 = + ( Perl, Practical, + Precocious + ); + +==> b1213.par <== +--continuation-indentation=8 +--ignore-old-breakpoints +--indent-columns=5 +--line-up-parentheses +--maximum-line-length=35 + ==> b1214.in <== # S1 eval { diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 6b6f1bd0..8a4c83c8 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -3873,46 +3873,28 @@ EOM $bond_str = NO_BREAK; } - # in older version of perl, use strict can cause problems with - # breaks before bare words following opening parens. For example, - # this will fail under older versions if a break is made between - # '(' and 'MAIL': use strict; open( MAIL, "a long filename or - # command"); close MAIL; + # OLD COMMENT: In older version of perl, use strict can cause + # problems with breaks before bare words following opening parens. + # For example, this will fail under older versions if a break is + # made between '(' and 'MAIL': + + # use strict; open( MAIL, "a long filename or command"); close MAIL; + + # NEW COMMENT: Third fix for b1213: + # This option does not seem to be needed any longer, and it can + # cause instabilities. It can be turned off, but to minimize + # changes to existing formatting it is retained only in the case + # where the previous token was 'open' and there was no line break. + # Even this could eventually be removed if it causes instability. if ( $type eq '{' ) { - if ( $token eq '(' && $next_nonblank_type eq 'w' ) { - - # but it's fine to break if the word is followed by a '=>' - # or if it is obviously a sub call - my $i_next_next_nonblank = $i_next_nonblank + 1; - my $next_next_type = $types_to_go[$i_next_next_nonblank]; - if ( $next_next_type eq 'b' - && $i_next_nonblank < $max_index_to_go ) - { - $i_next_next_nonblank++; - $next_next_type = $types_to_go[$i_next_next_nonblank]; - } - - # We'll check for an old breakpoint and keep a leading - # bareword if it was that way in the input file. - # Presumably it was ok that way. For example, the - # following would remain unchanged: - # - # @months = ( - # January, February, March, April, - # May, June, July, August, - # September, October, November, December, - # ); - # - # This should be sufficient: - if ( - !$old_breakpoint_to_go[$i] - && ( $next_next_type eq ',' - || $next_next_type eq '}' ) - ) - { - $bond_str = NO_BREAK; - } + if ( $token eq '(' + && $next_nonblank_type eq 'w' + && $last_nonblank_type eq 'k' + && $last_nonblank_token eq 'open' + && !$old_breakpoint_to_go[$i] ) + { + $bond_str = NO_BREAK; } }