]> git.donarmstrong.com Git - perltidy.git/commitdiff
fix b1371
authorSteve Hancock <perltidy@users.sourceforge.net>
Thu, 7 Jul 2022 17:26:29 +0000 (10:26 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Thu, 7 Jul 2022 17:26:29 +0000 (10:26 -0700)
dev-bin/run_convergence_tests.pl.data
lib/Perl/Tidy/Formatter.pm

index eba60edeb626ed404b2be0b145864f4e4fb70a2f..9ef02cc582227212a800f85815828bb9d21cde06 100644 (file)
@@ -10110,6 +10110,39 @@ my ( $m, $i, $j ) =(
 --nowant-right-space='='
 --want-break-before='='
 
+==> b1371.in <==
+# S1
+my (
+$xpos,
+$ypos,
+$font_size
+) =(
+       100,
+       700,
+       12
+);
+
+# S2
+my (
+$xpos,
+$ypos,
+$font_size
+  )
+  =(
+     100,
+     700,
+     12
+  );
+
+
+==> b1371.par <==
+--break-before-all-operators
+--extended-line-up-parentheses
+--indent-columns=0
+--keep-old-breakpoints-before=' )'
+--maximum-line-length=12
+--nowant-right-space='='
+
 ==> b140.in <==
 $cmd[ $i ]=[
         $s, $e, $cmd, \@hunk, $i ] ;
index 5dce2462e4ec14b6b82405867c2ad0d6b45a8167..9bcd31a3d59056e74379645f87ec8ee38b5e72c3 100644 (file)
@@ -21828,17 +21828,20 @@ sub get_available_spaces_to_go {
             # find the position if we break at the '='
             my $i_test = $ii_last_equals;
 
-            # Fix for issue b1229, check for break before
-            # Fix for issue b1356, i_test must never be blank
+            # Fix for issue b1229, check if want break before this token
+            # Fix for issue b1356, if i_test is a blank, the leading spaces may
+            #   be incorrect (if it was an interline blank).
             # Fix for issue b1357 .. b1370, i_test must be prev nonblank
             #   ( the ci value for blanks can vary )
-            # See also b223
+            # See also case b223
+            # Fix for issue b1371-b1374 : all of these and the above are fixed
+            # by simply backing up one index and setting the leading spaces of
+            # a blank equal to that of the equals.
             if ( $want_break_before{ $types_to_go[$i_test] } ) {
-                my $i_prev_nb = $i_test - 1;
-                $i_prev_nb -= 1
-                  if ( $types_to_go[$i_prev_nb] eq 'b' );
-                $i_test = $i_prev_nb
-                  if ( $i_prev_nb > $ii_begin_line );
+                $i_test -= 1;
+                $leading_spaces_to_go[$i_test] =
+                  $leading_spaces_to_go[$ii_last_equals]
+                  if ( $types_to_go[$i_test] eq 'b' );
             }
             elsif ( $types_to_go[ $i_test + 1 ] eq 'b' ) { $i_test++ }