forked from lug/matterbridge
Fix linting
This commit is contained in:
@@ -231,17 +231,17 @@ func ClipMessage(text string, length int, clippingMessage string) string {
|
||||
|
||||
func ClipOrSplitMessage(text string, length int, clippingMessage string, splitMax int) []string {
|
||||
var msgParts []string
|
||||
var remainingText = text
|
||||
remainingText := text
|
||||
// Invariant of this splitting loop: No text is lost (msgParts+remainingText is the original text),
|
||||
// and all parts is guaranteed to satisfy the length requirement.
|
||||
for len(msgParts) < splitMax - 1 && len(remainingText) > length {
|
||||
for len(msgParts) < splitMax-1 && len(remainingText) > length {
|
||||
// Decision: The text needs to be split (again).
|
||||
var chunk string
|
||||
var wasted = 0
|
||||
wasted := 0
|
||||
// The longest UTF-8 encoding of a valid rune is 4 bytes (0xF4 0x8F 0xBF 0xBF, encoding U+10FFFF),
|
||||
// so we should never need to waste 4 or more bytes at a time.
|
||||
for wasted < 4 && wasted < length {
|
||||
chunk = remainingText[:length - wasted]
|
||||
chunk = remainingText[:length-wasted]
|
||||
if r, _ := utf8.DecodeLastRuneInString(chunk); r == utf8.RuneError {
|
||||
wasted += 1
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user