File tree Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -747,6 +747,18 @@ func (p *printer) intersperseComments(next token.Position, tok token.Token) (wro
747
747
// a top-level doc comment.
748
748
list = formatDocComment (list )
749
749
changed = true
750
+
751
+ if len (p .comment .List ) > 0 && len (list ) == 0 {
752
+ // The doc comment was removed entirely.
753
+ // Keep preceding whitespace.
754
+ p .writeCommentPrefix (p .posFor (p .comment .Pos ()), next , last , tok )
755
+ // Change print state to continue at next.
756
+ p .pos = next
757
+ p .last = next
758
+ // There can't be any more comments.
759
+ p .nextComment ()
760
+ return p .writeCommentSuffix (false )
761
+ }
750
762
}
751
763
for _ , c := range list {
752
764
p .writeCommentPrefix (p .posFor (c .Pos ()), next , last , tok )
Original file line number Diff line number Diff line change @@ -767,4 +767,8 @@ var _ = []T{ // lone comments
767
767
// in composite lit
768
768
}
769
769
770
+ func _() {}
771
+
772
+ func _() {}
773
+
770
774
/* This comment is the last entry in this file. It must be printed and should be followed by a newline */
Original file line number Diff line number Diff line change @@ -765,4 +765,9 @@ var _ = []T{// lone comments
765
765
// in composite lit
766
766
}
767
767
768
+ func _() {}
769
+
770
+ //
771
+ func _() {}
772
+
768
773
/* This comment is the last entry in this file. It must be printed and should be followed by a newline */
You can’t perform that action at this time.
0 commit comments