From dd426483bcb2e5c8592365c06c7ae96b3c20f242 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Sat, 15 May 2021 17:20:49 -0700 Subject: [PATCH] Slightly modify line breaks for -lp indentation --- lib/Perl/Tidy/Formatter.pm | 7 ++++--- local-docs/BugLog.pod | 14 +++++++++++++- 2 files changed, 17 insertions(+), 4 deletions(-) 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 + +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 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 -- 2.39.5