@@ -249,21 +249,23 @@ func WriteNewLine(builder *strings.Builder) {
249249func ConvertContentToComments (content []string , writer OutputWriter , commentDecorators ... CommentDecorator ) (comments []string ) {
250250 commentBuilder := strings.Builder {}
251251 for _ , commentContent := range content {
252- if newContent , limitReached := getContentAndResetBuilderIfLimitReached (len (comments ), commentContent , & commentBuilder , writer , commentDecorators ... ); limitReached {
252+ if newContent , limitReached := getContentAndResetBuilderIfLimitReached (len (comments ), commentContent , & commentBuilder , writer , commentDecorators ... ); limitReached && newContent != "" {
253253 comments = append (comments , newContent )
254254 }
255255 WriteContent (& commentBuilder , commentContent )
256256 }
257257 if commentBuilder .Len () > 0 || len (content ) == 0 {
258- comments = append (comments , decorate (len (comments ), commentBuilder .String (), commentDecorators ... ))
258+ if comment := decorate (len (comments ), commentBuilder .String (), commentDecorators ... ); comment != "" {
259+ comments = append (comments , comment )
260+ }
259261 }
260262 return
261263}
262264
263265func getContentAndResetBuilderIfLimitReached (commentCount int , newContent string , builder * strings.Builder , writer OutputWriter , commentDecorators ... CommentDecorator ) (content string , reached bool ) {
264266 limit := writer .SizeLimit (commentCount != 0 )
265- if limit = = 0 {
266- // No limit
267+ if limit < = 0 {
268+ // No limit
267269 return
268270 }
269271 if builder .Len ()+ decoratorsSize (commentCount , commentDecorators ... )+ len (newContent ) < limit {
0 commit comments