]> git.donarmstrong.com Git - perltidy.git/commitdiff
-drc should only delete commas repeated on the same line
authorSteve Hancock <perltidy@users.sourceforge.net>
Sat, 10 Feb 2024 15:11:51 +0000 (07:11 -0800)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sat, 10 Feb 2024 15:11:51 +0000 (07:11 -0800)
this avoids converting a side comment to a block comment

lib/Perl/Tidy/Formatter.pm

index dccd5a4257c700672c66007b313a3a47acd73c2e..173a029e4fc82d7673d0bfb9d955c0d737144ba5 100644 (file)
@@ -11325,9 +11325,18 @@ EOM
             if (   $last_nonblank_code_type eq ','
                 && $rOpts->{'delete-repeated-commas'} )
             {
-                # Could note this deletion as a possible future update:
-                ## $self->note_deleted_comma($input_line_number);
-                next;
+
+                # do not delete a comma repeated on a different line -
+                # this can cause problems, such as promoting a side comment
+                # to a block comment. See test 'mangle4.in'
+                if ( $KK == $Kfirst ) {
+                    ## but a warning could be issued
+                }
+                else {
+                    # Could note this deletion as a possible future update:
+                    ## $self->note_deleted_comma($input_line_number);
+                    next;
+                }
             }
 
             # remember input line index of first comma if -wtc is used