diff options
-rw-r--r-- | src/core.go | 1 | ||||
-rw-r--r-- | src/util/chars.go | 5 |
2 files changed, 6 insertions, 0 deletions
diff --git a/src/core.go b/src/core.go index 087c7df9..9d118a49 100644 --- a/src/core.go +++ b/src/core.go @@ -126,6 +126,7 @@ func Run(opts *Options, revision string) { return false } item.text, item.colors = ansiProcessor([]byte(transformed)) + item.text.TrimTrailingWhitespaces() item.text.Index = itemIndex item.origText = &data itemIndex++ diff --git a/src/util/chars.go b/src/util/chars.go index e36ab769..a57ba4bb 100644 --- a/src/util/chars.go +++ b/src/util/chars.go @@ -142,6 +142,11 @@ func (chars *Chars) TrailingWhitespaces() int { return whitespaces } +func (chars *Chars) TrimTrailingWhitespaces() { + whitespaces := chars.TrailingWhitespaces() + chars.slice = chars.slice[0 : len(chars.slice)-whitespaces] +} + func (chars *Chars) ToString() string { if runes := chars.optionalRunes(); runes != nil { return string(runes) |