]> git.donarmstrong.com Git - perltidy.git/commitdiff
Do not apply -xci if it causes maximum line length to be exceeded
authorSteve Hancock <perltidy@users.sourceforge.net>
Wed, 17 Feb 2021 15:35:35 +0000 (07:35 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Wed, 17 Feb 2021 15:35:35 +0000 (07:35 -0800)
lib/Perl/Tidy/Formatter.pm
local-docs/BugLog.pod

index f7f4c018439622acdcd5771ff6948fbbb1fff38f..77e30990ee364db1825988a9a0472061bbf6c00e 100644 (file)
@@ -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;
index c60a4eed5b9a1ace55d5bd6b7b9964819f2b4900..5d46dcbec050ca618a66cce45b76fc16a3cdb37b 100644 (file)
@@ -2,6 +2,11 @@
 
 =over 4
 
+=item B<Do not apply -xci if it would put tokens beyond the maximum line length>
+
+This update fixes cases b899 b935.
+17 Feb 2021.
+
 =item B<Do not weld to a hash brace>
 
 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<Avoid line breaks after token type 'G'>