From ef577a65094a38f82b2c18dfd3e524eb50748503 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Wed, 6 Mar 2019 19:05:05 +0900 Subject: Preserve the original color of each token when using --with-nth with --ansi Close #1500 --- src/util/chars.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/util/chars.go') diff --git a/src/util/chars.go b/src/util/chars.go index ec6fca0e..35b28297 100644 --- a/src/util/chars.go +++ b/src/util/chars.go @@ -171,3 +171,12 @@ func (chars *Chars) CopyRunes(dest []rune) { } return } + +func (chars *Chars) Wrap(prefix string, suffix string) { + if runes := chars.optionalRunes(); runes != nil { + runes = append(append([]rune(prefix), runes...), []rune(suffix)...) + chars.slice = *(*[]byte)(unsafe.Pointer(&runes)) + } else { + chars.slice = append(append([]byte(prefix), chars.slice...), []byte(suffix)...) + } +} -- cgit v1.2.3