From f8c644fa7ed5f4dead72347bdf1baaed30ca793d Mon Sep 17 00:00:00 2001 From: diamondburned Date: Fri, 19 Mar 2021 22:40:31 -0700 Subject: [PATCH] Allow empty texts with segments This commit allows segments in an empty text segment to account for segments with only an image. --- text/text_extras.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/text/text_extras.go b/text/text_extras.go index 143d827..9272e96 100644 --- a/text/text_extras.go +++ b/text/text_extras.go @@ -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 }