Skip to content

Commit

Permalink
julefmt: fix comment handling of trait declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Jan 15, 2025
1 parent 41fe0b0 commit 74bebdb
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/format.jule
Original file line number Diff line number Diff line change
Expand Up @@ -672,10 +672,22 @@ impl formatter {
self.fnDecl(m)
self.popRowComments(m.Token.Row)
}
self.addGlobalPaddingForComment(d.End.Row)
// Function declaration formatting won't add new-line.
// So add a new-line to complete "\n\n" if needed.
// addGlobalPaddingForComment adds one "\n" if needed.
pad := self.addGlobalPaddingForComment(d.End.Row) || self.seekCommentExcept(d.End.Row) != nil
if pad {
self.write("\n")
}
self.writeCommentsExcept(d.End.Row)
self.doneIndent()
self.write("\n}")
// If padding enabled, there is comment.
// So comment writer will write a new-line after comment.
// Avoid to write a new-line after comments.
if !pad {
self.write("\n")
}
self.write("}")
self.popRowComments(d.End.Row)
self.row = d.End.Row
}
Expand Down

0 comments on commit 74bebdb

Please sign in to comment.