From: Steve Hancock Date: Mon, 12 Jul 2021 01:31:10 +0000 (-0700) Subject: Avoid line breaks before a slash in certain cases X-Git-Tag: 20210717~5 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=7afee4714bd1981d61ea4591afa4cfe56e8805af;p=perltidy.git Avoid line breaks before a slash in certain cases --- diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 4e995849..a24492de 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -3728,8 +3728,9 @@ EOM ) # or we might be followed by the start of a quote, - # fixes c039. - || substr( $next_nonblank_token, 0, 1 ) eq '/' + # and this is not an existing breakpoint; fixes c039. + || !$old_breakpoint_to_go[$i] + && substr( $next_nonblank_token, 0, 1 ) eq '/' ) { @@ -3760,7 +3761,8 @@ EOM # Fix for c039 elsif ( $type eq 'w' ) { $bond_str = NO_BREAK - if ( substr( $next_nonblank_token, 0, 1 ) eq '/' ); + if ( !$old_breakpoint_to_go[$i] + && substr( $next_nonblank_token, 0, 1 ) eq '/' ); } my $bond_str_2 = $bond_str; @@ -5914,7 +5916,8 @@ sub respace_tokens { $is_block_without_semicolon{ $last_nonblank_block_type} || $last_nonblank_block_type =~ /$SUB_PATTERN/ - || $last_nonblank_block_type =~ /^\w+:$/ ) + || $last_nonblank_block_type =~ /^\w+:$/ + ) ) || $last_nonblank_type eq ';' ) @@ -21410,9 +21413,12 @@ sub make_paren_name { # an isolated brace ############################################################# my $is_isolated_block_brace = $block_type_to_go[$ibeg] - && ( $i_terminal == $ibeg + && ( + $i_terminal == $ibeg || $is_if_elsif_else_unless_while_until_for_foreach{ - $block_type_to_go[$ibeg] } ); + $block_type_to_go[$ibeg] + } + ); # only do this for a ':; which is aligned with its leading '?' my $is_unaligned_colon = $types_to_go[$ibeg] eq ':' && !$is_leading; diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index ca984434..8bc5b17d 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -2,6 +2,13 @@ =over 4 +=item B + +This is a modification to the previous update for case c039 which prevents a line break before a '/' character which follows a bareword or possible indirect object. This rule +will be only be used to prevent creating new line breaks. Existing line breaks can remain. + +11 Jul 2021 + =item B Testing with side comments produced an error in the following snippet: