From 84a6af20be8699efa6cbb7e25575af183e74a3fa Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Wed, 7 Aug 2024 16:53:57 -0700 Subject: [PATCH] fix minor formatting issue, c385 --- CHANGES.md | 4 ++-- bin/perltidy | 2 +- lib/Perl/Tidy/Formatter.pm | 24 ++++++++++++++++++------ 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 8098ec85..f498cb25 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,13 +2,13 @@ ## 2024 05 11.09 - - Add --timeout-in-seconds=n, or -to=n. When the standard input supplies + - Add --timeout-in-seconds=n, or -tos=n. When the standard input supplies the input stream, and the input has not been received within n seconds, perltidy will end with a timeout message. The intention is to catch a situation where perltidy is accidentally invoked without a file to process and therefore waits for input from the system standard input (stdin), which never arrives. The default is n=10. - This check can be turned off with -to=0. + This check can be turned off with -tos=0. - Add parameter --closing-side-comment-exclusion-list=string, or -cscxl=string, where string is a list of block types to exclude diff --git a/bin/perltidy b/bin/perltidy index 15cb9d48..033bc420 100755 --- a/bin/perltidy +++ b/bin/perltidy @@ -420,7 +420,7 @@ other words that the input code is 'untidy' according to the formatting parameters. If this is not the case, an error message noting this is produced. This flag has no other effect on the functioning of perltidy. -=item B<-to=n>, B<--timeout-in-seconds=n> +=item B<-tos=n>, B<--timeout-in-seconds=n> When the standard input supplies the input stream, and the input has not been received within B seconds, perltidy will end with a timeout message. The diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 9c1650cc..fb3225a5 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -8501,7 +8501,7 @@ sub set_CODE_type { $CODE_type = $no_leading_space ? 'SBCX' : 'SBC'; next; } - elsif ($last_line_had_side_comment + elsif ( $last_line_had_side_comment && !$rOpts_maximum_consecutive_blank_lines && $rLL->[$Kfirst]->[_LEVEL_] > 0 ) { @@ -9906,7 +9906,7 @@ sub initialize_warn_hash { # Special check for -wvt # Deactivated for now to allow -wvt in perltidyrc files. This can # eventually be removed if allowing this does not cause problems. - elsif (0 + elsif ( 0 && ( $opt eq 'u' || $opt eq 'c' ) && $long_name eq 'warn-variable-types' ) { @@ -14557,7 +14557,7 @@ sub count_list_elements { } # remember the name of the first item, maybe something like '$self' - elsif ($sigil eq '$' + elsif ( $sigil eq '$' && !$self_name && !$arg_count ) { @@ -35566,7 +35566,7 @@ sub undo_contained_ci { } # we might be able to handle a pad of -1 by removing a blank - # token + # token. if ( $pad_spaces < 0 ) { # Deactivated for -kpit due to conflict. This block deletes @@ -35574,9 +35574,21 @@ sub undo_contained_ci { # but it may conflict with user spacing requests. For now # it is just deactivated if the -kpit option is used. if ( $pad_spaces == -1 ) { - if ( $ipad > $ibeg + if ( + $ipad > $ibeg && $types_to_go[ $ipad - 1 ] eq 'b' - && !%keyword_paren_inner_tightness ) + && !%keyword_paren_inner_tightness + + # additional tests added for c385: + && ( + $types_to_go[$inext_next] eq $types_to_go[$ipad] + || ( + $types_to_go[$ipad] eq '!' + && ( $types_to_go[ $ipad + 1 ] eq + $types_to_go[$inext_next] ) + ) + ) + ) { $self->pad_token( $ipad - 1, $pad_spaces ); } -- 2.39.5