From b955a7c4f4ce432627bb726a78d007300fb93b9f Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Wed, 17 Feb 2021 07:35:35 -0800 Subject: [PATCH] Do not apply -xci if it causes maximum line length to be exceeded --- lib/Perl/Tidy/Formatter.pm | 13 +++++++++++++ local-docs/BugLog.pod | 7 ++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index f7f4c018..77e30990 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -8074,6 +8074,19 @@ sub extended_ci { $rOpts_maximum_line_length ) ); + # Do not apply -xci if adding extra ci will put the container contents + # beyond the line length limit (fixes cases b899 b935) + my $starting_indent = 0; + if ( !$rOpts_variable_maximum_line_length ) { + my $level = $rLL->[$K_opening]->[_LEVEL_]; + my $ci_level = $rLL->[$K_opening]->[_CI_LEVEL_]; + $starting_indent = $rOpts_indent_columns * $level + + $ci_level * $rOpts_continuation_indentation; + } + next + if ( $starting_indent + $rOpts_continuation_indentation > + $rOpts_maximum_line_length ); + # This becomes the next controlling container push @seqno_stack, $seqno_top if ($seqno_top); $seqno_top = $seqno; diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index c60a4eed..5d46dcbe 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -2,6 +2,11 @@ =over 4 +=item B + +This update fixes cases b899 b935. +17 Feb 2021. + =item B The reason is that it has a very strong bond strength to the next token, so a @@ -10,7 +15,7 @@ like '@{' but even that caused blinking states (cases b751, b779). This will not change much existing code. This update fixes cases b751 b779. -16 Feb 2021. +16 Feb 2021, eb2f4e7. =item B -- 2.39.5