Allow empty texts with segments

This commit allows segments in an empty text segment to account for
segments with only an image.
This commit is contained in:
diamondburned 2021-03-19 22:40:31 -07:00
parent c7d4473c23
commit f8c644fa7e
1 changed files with 4 additions and 2 deletions

View File

@ -11,7 +11,9 @@ func SolidColor(rgb uint32) uint32 {
return (rgb << 8) | 0xFF
}
// IsEmpty returns true if the given rich segment's content is empty.
// IsEmpty returns true if the given rich segment's content is empty. Note that
// a rich text is not necessarily empty if the content is empty, because there
// may be images within the segments.
func (r Rich) IsEmpty() bool {
return r.Content == ""
return r.Content == "" && len(r.Segments) == 0
}