From: Steve Hancock <perltidy@users.sourceforge.net> Date: Sun, 16 May 2021 00:20:49 +0000 (-0700) Subject: Slightly modify line breaks for -lp indentation X-Git-Tag: 20210402.01~38 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=dd426483bcb2e5c8592365c06c7ae96b3c20f242;p=perltidy.git Slightly modify line breaks for -lp indentation --- diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 93706246..06f95b6d 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -18098,10 +18098,11 @@ sub get_available_spaces_to_go { || ( $bbc_flag && $bbc_flag >= 2 ) # or we are beyond the 1/4 point and there was an old - # break at the equals + # break at an assignment (not '=>') [fix for b1035] || ( $gnu_position_predictor > $mll - $rOpts_maximum_line_length * 3 / 4 + && $types_to_go[$last_equals] ne '=>' && ( $old_breakpoint_to_go[$last_equals] || ( $last_equals > 0 @@ -18347,8 +18348,8 @@ sub get_available_spaces_to_go { if ( $type eq '=>' ) { $gnu_arrow_count{$total_depth}++; - # tentatively treating '=>' like '=' for estimating breaks - # TODO: this could use some experimentation + # remember '=>' like '=' for estimating breaks (but see above note + # for b1035) $last_gnu_equals{$total_depth} = $max_index_to_go; } diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index e18470ba..cc2bbe13 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -2,6 +2,18 @@ =over 4 +=item B<Slightly modify line breaks for -lp indentation> + +Random testing produced a edge case of formatting instability for -lp indentation +which was traced to checking for an old line break at a '=>'. This has been fixed. +Some existing formatting with deeply nested structures may be slightly changed due +to the fix, but most existing formatting will be unchanged. + +This fixes b1035. + +15 May 2021. + + =item B<Rewrite coding for -bom flag> Random testing produced some examples of formatting instability involving the @@ -97,7 +109,7 @@ old b977 fix: This update fixes case b1120 and revises the fix for b977. -13 May 2021. +13 May 2021, d0ac5e9. =item B<Adjust tolerances for some line length tests>