]> git.donarmstrong.com Git - perltidy.git/commitdiff
fix b1433, b1434, b1435
authorSteve Hancock <perltidy@users.sourceforge.net>
Mon, 28 Nov 2022 15:59:26 +0000 (07:59 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Mon, 28 Nov 2022 15:59:26 +0000 (07:59 -0800)
dev-bin/run_convergence_tests.pl.data
lib/Perl/Tidy/Formatter.pm

index 09d4813ba97943020d8b2a782ea182ce45275c03..b062e2ab937df8cb11d6945b42aadddea605036f 100644 (file)
@@ -11096,6 +11096,45 @@ $last = after (
 --space-function-paren
 --want-trailing-commas='b'
 
+==> b1433.in <==
+    return (
+        ( $val || !exists $opts{$opt} ) ?
+          do { $opts{$opt} = 1 } :
+          do { delete $opts{$opt}; 1 }
+      );
+
+    return (
+        ( $val || !exists $opts{$opt} ) ? do { $opts{$opt} = 1 }
+        :
+          do { delete $opts{$opt}; 1 }
+    );
+
+==> b1433.par <==
+--break-after-all-operators
+--keep-old-breakpoints-after=':'
+--variable-maximum-line-length
+
+==> b1435.in <==
+(-r _)?do{do$vshnurc;&err($@)}
+       :
+       &err(
+    "Cannot read $vshnurc")
+       if-f$vshnurc;
+
+(-r _)?
+       do{do$vshnurc;&err($@)}:
+       &err(
+    "Cannot read $vshnurc")
+       if-f$vshnurc;
+
+
+==> b1435.par <==
+--noadd-whitespace
+--break-after-all-operators
+--continuation-indentation=7
+--keep-old-breakpoints-after=':'
+--maximum-line-length=34
+
 ==> b146.in <==
 # State 1
 
index f729d0247f80b75a30876e032dd8e9aee46d95cb..5561fba0a0543d72ca85620ce8eccd205131783f 100644 (file)
@@ -8861,6 +8861,19 @@ EOM
     return ( $severe_error, $rqw_lines );
 } ## end sub resync_lines_and_tokens
 
+my %is_soft_break_type;
+
+BEGIN {
+
+    # Soft breaks are needed to avoid conflicts for token types which might be
+    # treated with special logic for chains.  Fixes b1433, 1434, 1435.
+    # NOTE: $type is used as the hash key for now; if other container tokens
+    # are added it might be necessary to use a token/type mixture.
+    my @q = qw# -> ? : && || + - / * #;
+    @is_soft_break_type{@q} = (1) x scalar(@q);
+
+}
+
 sub keep_old_line_breaks {
 
     # Called once per file to find and mark any old line breaks which
@@ -8936,7 +8949,7 @@ sub keep_old_line_breaks {
         if ( !$seqno ) {
             my $type = $rLL->[$KK]->[_TYPE_];
             if ( $rkeep_break_hash->{$type} ) {
-                $rbreak_hash->{$KK} = 1;
+                $rbreak_hash->{$KK} = $is_soft_break_type{$type} ? 2 : 1;
             }
         }
 
@@ -8968,7 +8981,10 @@ sub keep_old_line_breaks {
                         }
                     }
                 }
-                $rbreak_hash->{$KK} = 1 if ($match);
+                if ($match) {
+                    my $type = $rLL->[$KK]->[_TYPE_];
+                    $rbreak_hash->{$KK} = $is_soft_break_type{$type} ? 2 : 1;
+                }
             }
         }
     };