]> git.donarmstrong.com Git - perltidy.git/commitdiff
Slightly modify line breaks for -lp indentation
authorSteve Hancock <perltidy@users.sourceforge.net>
Sun, 16 May 2021 00:20:49 +0000 (17:20 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sun, 16 May 2021 00:20:49 +0000 (17:20 -0700)
lib/Perl/Tidy/Formatter.pm
local-docs/BugLog.pod

index 937062468b31a480058d0b905f031f2191f4b1aa..06f95b6d3698683bd2811a411d952d5e061cac8e 100644 (file)
@@ -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;
         }
 
index e18470baf7e30175d49c783aaeb8471e0b1d9a32..cc2bbe13aa5a1e18afa6498c583ddee705bfdcfc 100644 (file)
@@ -2,6 +2,18 @@
 
 =over 4
 
+=item B<Slightly modify line breaks for -lp indentation>
+
+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<Rewrite coding for -bom flag>
 
 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<Adjust tolerances for some line length tests>