From 40fe314224e7cb32dd444b89a38d6958a7124ba0 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Sat, 10 Feb 2024 07:11:51 -0800 Subject: [PATCH] -drc should only delete commas repeated on the same line this avoids converting a side comment to a block comment --- lib/Perl/Tidy/Formatter.pm | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index dccd5a42..173a029e 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -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 -- 2.39.5