From 9f15b9d2ff56c957c01e79df76114b2f61c4bc31 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Thu, 15 Apr 2021 17:52:50 -0700 Subject: [PATCH] Fix rare line break problem --- lib/Perl/Tidy/Formatter.pm | 10 +++++++++- local-docs/BugLog.pod | 30 ++++++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 6cc468c6..01704ff6 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -15433,7 +15433,15 @@ sub set_continuation_breaks { } $last_old_breakpoint_count = $old_breakpoint_count; - if ( $old_breakpoint_to_go[$i] ) { + + # Fixed for case b1097 to not consider old breaks at highly + # stressed locations, such as types 'L' and 'R'. It might be + # useful to generalize this concept in the future by looking at + # actual bond strengths. + if ( $old_breakpoint_to_go[$i] + && $type ne 'L' + && $next_nonblank_type ne 'R' ) + { $i_line_end = $i; $i_line_start = $i_next_nonblank; diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index 6b28c130..3d8cb8af 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -3,6 +3,32 @@ =over 4 +=item B + +Random testing produced case b1097 with this parameter set + + --brace-vertical-tightness-closing=1 + --continuation-indentation=8 + --indent-columns=10 + --maximum-line-length=36 + +and either this output + + my (@files) = @{ + $args{-files} }; + +or this output + + my (@files) = + @{ $args{-files} + }; + +The different results were caused by the unusual combination of parameters. +The problem was fixed by not allowing the formatter to consider existing breaks +at highly stressed locations such as these. + +15 Apr 2021. + =item B Random testing produced case b994 with unstable formatting: @@ -25,7 +51,7 @@ The line 'sub :' was being correctly parsed but the following opening block brace was not correctly marked as an anonymous sub brace. This fixes cases b994 and b1053. -15 Apr 2021. +15 Apr 2021, 84c1123. =item B @@ -36,7 +62,7 @@ having the tokenizer send a signal to the formatter if a block type was guessed. The formatter has more information and can fix the problem. This fixes case b1085. -11 Apr 2021. +11 Apr 2021, 7d23bf4. =item B -- 2.39.5