From: Steve Hancock Date: Tue, 9 Feb 2021 14:53:58 +0000 (-0800) Subject: Modified a rule for breaking lines at old commas X-Git-Tag: 20210402~57 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=5c236619b0273c8042a6abbd7a3b5056b7af746f;p=perltidy.git Modified a rule for breaking lines at old commas --- diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index eb0eb50a..05b2e2d1 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -3579,8 +3579,6 @@ EOM # add any bias set by sub scan_list at old comma break points $bond_str += $bond_strength_to_go[$i]; - # Avoid breaking at a useless terminal comma - $bond_str += 0.001 if ( $next_nonblank_type eq '}' ); } # bias left token @@ -14325,6 +14323,8 @@ sub set_continuation_breaks { # (2) there was exactly one old break before the first comma break # (3) OLD: there are multiple old comma breaks # (3) NEW: there are one or more old comma breaks (see return example) + # (4) the first comma is at the starting level ... + # ... fixes cases b064 b065 b068 b210 b747 # # For example, we will follow the user and break after # 'print' in this snippet: @@ -14352,8 +14352,10 @@ sub set_continuation_breaks { # ; # my $i_first_comma = $comma_index[$dd]->[0]; - if ( $old_breakpoint_to_go[$i_first_comma] ) { - my $level_comma = $levels_to_go[$i_first_comma]; + my $level_comma = $levels_to_go[$i_first_comma]; + if ( $old_breakpoint_to_go[$i_first_comma] + && $level_comma == $levels_to_go[0] ) + { my $ibreak = -1; my $obp_count = 0; for ( my $ii = $i_first_comma - 1 ; $ii >= 0 ; $ii -= 1 ) { diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index fe6c3620..ea3cb1a6 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -2,6 +2,17 @@ =over 4 +=item B + +Random testing produced some blinking cases resulting from the treatment of old +line breaks at commas not contained within containers. The following cases +were fixed with this update: + +b064 b065 b068 b210 b747 + +This change has no effect on scripts with normal parameter values. +9 Feb 2021. + =item B A number of cases of blinking states were traced to code which biased @@ -17,37 +28,7 @@ b297 b299 b302 b304 b305 b307 b310 b311 b312 b313 b314 b315 b316 b317 b318 b319 b320 b321 b322 b323 b324 b325 b326 b327 b329 b330 b331 b332 b333 b334 b335 b336 b337 b338 b339 b340 b341 b342 b343 b344 b345 b346 b347 b348 b349 -8 Feb 2021. - -=item B - -Given the following input line with a length of 81, the default formatting -will break at the last comma: - - emit_subroutine_test( $test_file, $name, $capitalization_scheme, $failures ); - - # perltidy -sil=1 -iob - emit_subroutine_test( $test_file, $name, $capitalization_scheme, - $failures ); - -But if the input line has a comma at the end of the list - - emit_subroutine_test( $test_file, $name, $capitalization_scheme, $failures, ); - -# Then the break is at the last comma - - # OLD: perltidy -sil=1 -iob - emit_subroutine_test( $test_file, $name, $capitalization_scheme, $failures, - ); - -This update causes the break to be at the previous comma, so that the output -is similar to the output without the needless ending comma: - - # NEW: perltidy -sil=1 -iob - emit_subroutine_test( $test_file, $name, $capitalization_scheme, - $failures, ); - -8 Feb 2021. +8 Feb 2021, 66be455. =item B