]> git.donarmstrong.com Git - perltidy.git/commitdiff
Allow --delete-side-comments to work with -nanl
authorSteve Hancock <perltidy@users.sourceforge.net>
Fri, 18 Jun 2021 00:28:36 +0000 (17:28 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Fri, 18 Jun 2021 00:28:36 +0000 (17:28 -0700)
lib/Perl/Tidy/Formatter.pm
lib/Perl/Tidy/LineSink.pm
local-docs/BugLog.pod

index 7ffd2bbe6b0d6b45de3db4d3875720acd7212cc4..9bae006e78be40721f5bceffd66afb115222ea2b 100644 (file)
@@ -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_];
index 0dc09732b3341737e8a9581c33ddd4242345179f..cb31b6dcc1ffbd3ca62c8951ee6c5b3966d347f5 100644 (file)
@@ -91,6 +91,12 @@ EOM
     }, $class;
 }
 
+sub set_line_separator {
+    my ( $self, $val ) = @_;
+    $self->{_line_separator} = $val;
+    return;
+}
+
 sub write_line {
 
     my ( $self, $line ) = @_;
index e9b658cef646f98e3ef1c6ae585e7f87583925a9..9de60cd6d2258adc44d60b7133139fbcc79092d2 100644 (file)
@@ -2,6 +2,19 @@
 
 =over 4
 
+=item B<Allow --delete-side-comments to work with -nanl>
+
+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<Update welding rule to avoid unstable states>
 
 Testing with random input parameters produced a formatting instability