Always prepend ANSI reset code before re-assembling tokens

This commit is contained in:
Junegunn Choi
2019-03-07 10:47:09 +09:00
parent e00e7e1e56
commit 85c1f8a9e0
4 changed files with 9 additions and 7 deletions

View File

@@ -172,11 +172,11 @@ func (chars *Chars) CopyRunes(dest []rune) {
return
}
func (chars *Chars) Wrap(prefix string, suffix string) {
func (chars *Chars) Prepend(prefix string) {
if runes := chars.optionalRunes(); runes != nil {
runes = append(append([]rune(prefix), runes...), []rune(suffix)...)
runes = append([]rune(prefix), runes...)
chars.slice = *(*[]byte)(unsafe.Pointer(&runes))
} else {
chars.slice = append(append([]byte(prefix), chars.slice...), []byte(suffix)...)
chars.slice = append([]byte(prefix), chars.slice...)
}
}