]> git.donarmstrong.com Git - perltidy.git/commitdiff
Improve treatment of -vmll with -wn
authorSteve Hancock <perltidy@users.sourceforge.net>
Thu, 8 Apr 2021 22:44:33 +0000 (15:44 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Thu, 8 Apr 2021 22:44:33 +0000 (15:44 -0700)
lib/Perl/Tidy/Formatter.pm
local-docs/BugLog.pod

index 2eeeb4effd71697401445bf575a37bb36e7343f6..5134f053a8a7b1dcf4c38c01a4b2f31ec02821a3 100644 (file)
@@ -7224,33 +7224,36 @@ EOM
             my $level    = $rLL->[$Kref]->[_LEVEL_];
             my $ci_level = $rLL->[$Kref]->[_CI_LEVEL_];
 
-            if ( !$rOpts_variable_maximum_line_length ) {
+            $starting_indent = $rOpts_indent_columns * $level +
+              $ci_level * $rOpts_continuation_indentation;
 
-                $starting_indent = $rOpts_indent_columns * $level +
-                  $ci_level * $rOpts_continuation_indentation;
-
-                # Switch to using the outer opening token as the reference
-                # point if a line break before it would make a longer line.
-                # Fixes case b1055 and is also an alternate fix for b1065.
-                my $level_oo = $rLL->[$Kouter_opening]->[_LEVEL_];
-                if ( $Kref < $Kouter_opening ) {
-                    my $ci_level_oo = $rLL->[$Kouter_opening]->[_CI_LEVEL_];
-                    my $lentot_oo =
-                      $rLL->[ $Kouter_opening - 1 ]->[_CUMULATIVE_LENGTH_];
-                    my $starting_indent_oo = $rOpts_indent_columns * $level_oo +
-                      $ci_level_oo * $rOpts_continuation_indentation;
-                    if ( $lentot_oo - $starting_lentot <
-                        $starting_indent_oo - $starting_indent )
-                    {
-                        $Kref            = $Kouter_opening;
-                        $level           = $level_oo;
-                        $ci_level        = $ci_level_oo;
-                        $starting_lentot = $lentot_oo;
-                        $starting_indent = $starting_indent_oo;
-                    }
+            # Switch to using the outer opening token as the reference
+            # point if a line break before it would make a longer line.
+            # Fixes case b1055 and is also an alternate fix for b1065.
+            my $level_oo = $rLL->[$Kouter_opening]->[_LEVEL_];
+            if ( $Kref < $Kouter_opening ) {
+                my $ci_level_oo = $rLL->[$Kouter_opening]->[_CI_LEVEL_];
+                my $lentot_oo =
+                  $rLL->[ $Kouter_opening - 1 ]->[_CUMULATIVE_LENGTH_];
+                my $starting_indent_oo = $rOpts_indent_columns * $level_oo +
+                  $ci_level_oo * $rOpts_continuation_indentation;
+                if ( $lentot_oo - $starting_lentot <
+                    $starting_indent_oo - $starting_indent )
+                {
+                    $Kref            = $Kouter_opening;
+                    $level           = $level_oo;
+                    $ci_level        = $ci_level_oo;
+                    $starting_lentot = $lentot_oo;
+                    $starting_indent = $starting_indent_oo;
                 }
             }
 
+           # Revised -vmll treatment to fix cases b866 b1074 b1075 b1084 b1086
+           # b1087 b1088
+            if ($rOpts_variable_maximum_line_length) {
+                $starting_indent -= $level * $rOpts_indent_columns;
+            }
+
             # Avoid problem areas with the -wn -lp combination.
             # The combination -wn -lp -dws -naws does not work well and can
             # cause blinkers. See case b1020. It will probably only occur
index 8afb381c0c1e85226fbd8b648e4daf82d20ded77..5911c94d72c5deabd1971b93587c99f9f7de57e6 100644 (file)
@@ -3,6 +3,15 @@
 
 =over 4
 
+=item B<Improve treatment of -vmll with -wn>
+
+Random testing showed a weakness in the treatment of the -vmll flag
+in combination with the -wn flag.  This has been fixed.
+
+This fixes cases b866 b1074 b1075 b1084 b1086 b1087 b1088
+
+8 Apr 2021.
+
 =item B<Merge weld rule 6 into rule 3>
 
 One of the welding rules, RULE 6, has been merged into RULE 3 for
@@ -11,7 +20,7 @@ followed by a bare word, which can cause instability in some cases.
 The updated code is less restrictive and fixes some cases
 recently found with random testing, b1078 b1091.
 
-8 Apr 2021.
+8 Apr 2021, f28ab55.
 
 =item B<Moved logic of previous update to the FileWriter module>
 
@@ -19,7 +28,7 @@ The previous update regarding blank line generation was not sufficiently
 general to handle all possible parameter combinations. The problem was solved
 and simplified by moving the logic to a lower level, in the FileWriter module.
 
-6 Apr 2021.
+6 Apr 2021, 756e930.
 
 =item B<Fix problem with excess blank line generation with -blao>
 
@@ -41,7 +50,7 @@ and the following parameters
 When run, blank lines keep getting generated until the maximum is reached.
 This has been fixed.
 
-6 Apr 2021.
+6 Apr 2021, 9216298.
 
 
 =item B<Fix edge case involving -wn and -lp or -bbao>