aboutsummaryrefslogtreecommitdiff
path: root/ui/messages
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2018-04-24 22:49:41 +0300
committerTulir Asokan <tulir@maunium.net>2018-04-24 22:50:04 +0300
commitd7d654e2ec0a1d001f936b1575a3e6af3973a874 (patch)
tree4cb49fc74b7ebc8a026c434dcb8331a0f3ba9fc7 /ui/messages
parent6aceb4f8d2061fb99fd16deda58f4807d81a6ff7 (diff)
Flatten calculateBufferWithText() and gofmt
Diffstat (limited to 'ui/messages')
-rw-r--r--ui/messages/textbase.go20
1 files changed, 12 insertions, 8 deletions
diff --git a/ui/messages/textbase.go b/ui/messages/textbase.go
index 79913f8..f44d5d5 100644
--- a/ui/messages/textbase.go
+++ b/ui/messages/textbase.go
@@ -72,14 +72,18 @@ func (msg *BaseTextMessage) calculateBufferWithText(text tstring.TString, width
}
matches := boundaryPattern.FindAllStringIndex(extract.String(), -1)
- if len(matches) > 0 {
- match := matches[len(matches)-1]
- if len(match) > 1 {
- until := match[1]
- if until < len(extract) {
- extract = extract[:until]
- }
- }
+ if len(matches) == 0 {
+ continue
+ }
+
+ match := matches[len(matches)-1]
+ if len(match) < 2 {
+ continue
+ }
+
+ until := match[1]
+ if until < len(extract) {
+ extract = extract[:until]
}
}
msg.buffer = append(msg.buffer, extract)