diff options
author | Tulir Asokan <tulir@maunium.net> | 2018-04-30 12:01:43 +0300 |
---|---|---|
committer | Tulir Asokan <tulir@maunium.net> | 2018-04-30 12:01:43 +0300 |
commit | cc929ba89959b98a18252da357415d942d240854 (patch) | |
tree | 0eff4b6fa860ab69d2496c515e886995d2c89450 | |
parent | 74119ee2420439a313f50ae0906a628c4ac41863 (diff) |
Fix splitting long messages without spaces. Fixes #38
-rw-r--r-- | ui/messages/textbase.go | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/ui/messages/textbase.go b/ui/messages/textbase.go index f44d5d5..c241c0a 100644 --- a/ui/messages/textbase.go +++ b/ui/messages/textbase.go @@ -72,18 +72,14 @@ func (msg *BaseTextMessage) calculateBufferWithText(text tstring.TString, width } matches := boundaryPattern.FindAllStringIndex(extract.String(), -1) - 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] + if len(matches) > 0 { + match := matches[len(matches)-1] + if len(match) >= 2 { + until := match[1] + if until < len(extract) { + extract = extract[:until] + } + } } } msg.buffer = append(msg.buffer, extract) |