]> git.donarmstrong.com Git - perltidy.git/commitdiff
Modified a rule for breaking lines at old commas
authorSteve Hancock <perltidy@users.sourceforge.net>
Tue, 9 Feb 2021 14:53:58 +0000 (06:53 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Tue, 9 Feb 2021 14:53:58 +0000 (06:53 -0800)
lib/Perl/Tidy/Formatter.pm
local-docs/BugLog.pod

index eb0eb50a55ee183d4b2c795778ca13b7060cbca4..05b2e2d1188c84ef9e72bceecd0fb691098572d7 100644 (file)
@@ -3579,8 +3579,6 @@ EOM
                 # add any bias set by sub scan_list at old comma break points
                 $bond_str += $bond_strength_to_go[$i];
 
-                # Avoid breaking at a useless terminal comma
-                $bond_str += 0.001 if ( $next_nonblank_type eq '}' );
             }
 
             # bias left token
@@ -14325,6 +14323,8 @@ sub set_continuation_breaks {
         # (2) there was exactly one old break before the first comma break
         # (3) OLD: there are multiple old comma breaks
         # (3) NEW: there are one or more old comma breaks (see return example)
+        # (4) the first comma is at the starting level ...
+        #     ... fixes cases b064 b065 b068 b210 b747
         #
         # For example, we will follow the user and break after
         # 'print' in this snippet:
@@ -14352,8 +14352,10 @@ sub set_continuation_breaks {
         #          ;
         #
         my $i_first_comma = $comma_index[$dd]->[0];
-        if ( $old_breakpoint_to_go[$i_first_comma] ) {
-            my $level_comma = $levels_to_go[$i_first_comma];
+        my $level_comma   = $levels_to_go[$i_first_comma];
+        if (   $old_breakpoint_to_go[$i_first_comma]
+            && $level_comma == $levels_to_go[0] )
+        {
             my $ibreak      = -1;
             my $obp_count   = 0;
             for ( my $ii = $i_first_comma - 1 ; $ii >= 0 ; $ii -= 1 ) {
index fe6c36205f1f9254a0f0a5ea01f8bef47dc3f0d8..ea3cb1a611d9f5951c089808c1c83db11da14e19 100644 (file)
@@ -2,6 +2,17 @@
 
 =over 4
 
+=item B<Modified rule for breaking lines at old commas>
+
+Random testing produced some blinking cases resulting from the treatment of old
+line breaks at commas not contained within containers.  The following cases
+were fixed with this update:
+
+b064 b065 b068 b210 b747
+
+This change has no effect on scripts with normal parameter values.
+9 Feb 2021.
+
 =item B<Restrict references to old line breaks>
 
 A number of cases of blinking states were traced to code which biased
@@ -17,37 +28,7 @@ b297 b299 b302 b304 b305 b307 b310 b311 b312 b313 b314 b315 b316 b317 b318 b319
 b320 b321 b322 b323 b324 b325 b326 b327 b329 b330 b331 b332 b333 b334 b335 b336
 b337 b338 b339 b340 b341 b342 b343 b344 b345 b346 b347 b348 b349
 
-8 Feb 2021.
-
-=item B<Avoid breaking a line after an optional ending comma>
-
-Given the following input line with a length of 81, the default formatting
-will break at the last comma:
-
-    emit_subroutine_test( $test_file, $name, $capitalization_scheme, $failures );
-
-    # perltidy -sil=1 -iob
-    emit_subroutine_test( $test_file, $name, $capitalization_scheme,
-        $failures );
-
-But if the input line has a comma at the end of the list
-
-    emit_subroutine_test( $test_file, $name, $capitalization_scheme, $failures, );
-
-# Then the break is at the last comma
-    
-    # OLD: perltidy -sil=1 -iob
-    emit_subroutine_test( $test_file, $name, $capitalization_scheme, $failures,
-    );
-
-This update causes the break to be at the previous comma, so that the output
-is similar to the output without the needless ending comma:
-
-    # NEW: perltidy -sil=1 -iob
-    emit_subroutine_test( $test_file, $name, $capitalization_scheme,
-        $failures, );
-
-8 Feb 2021.
+8 Feb 2021, 66be455.
 
 =item B<Fix rare problem involving interaction of -olbn=n and -wn flags>