From dbfd8024830aa50b9896d558db54fdbafe545fca Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Thu, 17 Jun 2021 17:28:36 -0700 Subject: [PATCH] Allow --delete-side-comments to work with -nanl --- lib/Perl/Tidy/Formatter.pm | 13 ++++++++++--- lib/Perl/Tidy/LineSink.pm | 6 ++++++ local-docs/BugLog.pod | 13 +++++++++++++ 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 7ffd2bbe..9bae006e 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -4634,14 +4634,21 @@ sub make_closing_side_comment_prefix { && defined($Kfirst) && $rLL->[$Klimit]->[_TYPE_] eq '#' && ( $Klimit > $Kfirst || $CODE_type eq 'HSC' ) - && ( !$CODE_type || $CODE_type eq 'HSC' || $CODE_type eq 'IO' ); + && (!$CODE_type + || $CODE_type eq 'HSC' + || $CODE_type eq 'IO' + || $CODE_type eq 'NIN' ); - if ( $rOpts_delete_closing_side_comments + if ( + $rOpts_delete_closing_side_comments && !$delete_side_comment && defined($Kfirst) && $Klimit > $Kfirst && $rLL->[$Klimit]->[_TYPE_] eq '#' - && ( !$CODE_type || $CODE_type eq 'HSC' || $CODE_type eq 'IO' ) + && ( !$CODE_type + || $CODE_type eq 'HSC' + || $CODE_type eq 'IO' + || $CODE_type eq 'NIN' ) ) { my $token = $rLL->[$Klimit]->[_TOKEN_]; diff --git a/lib/Perl/Tidy/LineSink.pm b/lib/Perl/Tidy/LineSink.pm index 0dc09732..cb31b6dc 100644 --- a/lib/Perl/Tidy/LineSink.pm +++ b/lib/Perl/Tidy/LineSink.pm @@ -91,6 +91,12 @@ EOM }, $class; } +sub set_line_separator { + my ( $self, $val ) = @_; + $self->{_line_separator} = $val; + return; +} + sub write_line { my ( $self, $line ) = @_; diff --git a/local-docs/BugLog.pod b/local-docs/BugLog.pod index e9b658ce..9de60cd6 100644 --- a/local-docs/BugLog.pod +++ b/local-docs/BugLog.pod @@ -2,6 +2,19 @@ =over 4 +=item B + +The -nanl flag (--noadd-newlines) was preventing side comments from being +deleted, for example: + + # perltidy -dsc -nanl + calc() # side comment + +The same issue was happening for --delete-closing-side comments. +This has been fixed. + +18 Jun 2021. + =item B Testing with random input parameters produced a formatting instability -- 2.39.5