@@ -225,8 +225,6 @@ func (x *FileSyntax) Cleanup() {
225
225
if ww == 0 {
226
226
continue
227
227
}
228
- // **Check and remove empty RParen comments**
229
- stmt .RParen .Comments = removeEmptyComments (stmt .RParen .Comments )
230
228
if ww == 1 && len (stmt .RParen .Comments .Before ) == 0 {
231
229
// Collapse block into single line but keep the Line reference used by the
232
230
// parsed File structure.
@@ -250,22 +248,6 @@ func (x *FileSyntax) Cleanup() {
250
248
x .Stmt = x .Stmt [:w ]
251
249
}
252
250
253
- // removeEmptyComments removes empty comment sections.
254
- func removeEmptyComments (c Comments ) Comments {
255
- // Remove comments with empty tokens and zero position markers
256
- var newBefore []Comment
257
- for _ , cm := range c .Before {
258
- if cm .Token != "" || cm .Start .Line != 0 || cm .Start .Byte != 0 {
259
- newBefore = append (newBefore , cm )
260
- }
261
- }
262
-
263
- if len (newBefore ) == 0 && len (c .Suffix ) == 0 && len (c .After ) == 0 {
264
- return Comments {}
265
- }
266
- return Comments {Before : newBefore , Suffix : c .Suffix , After : c .After }
267
- }
268
-
269
251
func commentsAdd (x , y []Comment ) []Comment {
270
252
return append (x [:len (x ):len (x )], y ... )
271
253
}
@@ -895,7 +877,14 @@ func (in *input) parseLineBlock(start Position, token []string, lparen token) *L
895
877
in .Error (fmt .Sprintf ("syntax error (unterminated block started at %s:%d:%d)" , in .filename , x .Start .Line , x .Start .LineRune ))
896
878
case ')' :
897
879
rparen := in .lex ()
898
- x .RParen .Before = comments
880
+ // Filter out comments with Start.Line == 0
881
+ var filteredComments []Comment
882
+ for _ , c := range comments {
883
+ if c .Start .Line > 0 {
884
+ filteredComments = append (filteredComments , c )
885
+ }
886
+ }
887
+ x .RParen .Before = filteredComments
899
888
x .RParen .Pos = rparen .pos
900
889
if ! in .peek ().isEOL () {
901
890
in .Error ("syntax error (expected newline after closing paren)" )
0 commit comments