From 90b0cd44ac8fb9a6965c3dcf050f0e6aa2e90121 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Fri, 28 Aug 2015 21:23:10 +0900 Subject: Should not strip ANSI codes when --ansi is not set --- src/item.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/item.go') diff --git a/src/item.go b/src/item.go index 2ab8a78c..12ca3dfb 100644 --- a/src/item.go +++ b/src/item.go @@ -94,15 +94,19 @@ func (item *Item) Rank(cache bool) Rank { } // AsString returns the original string -func (item *Item) AsString() string { - return *item.StringPtr() +func (item *Item) AsString(stripAnsi bool) string { + return *item.StringPtr(stripAnsi) } // StringPtr returns the pointer to the original string -func (item *Item) StringPtr() *string { +func (item *Item) StringPtr(stripAnsi bool) *string { if item.origText != nil { - trimmed, _, _ := extractColor(string(*item.origText), nil) - return &trimmed + if stripAnsi { + trimmed, _, _ := extractColor(string(*item.origText), nil) + return &trimmed + } + orig := string(*item.origText) + return &orig } str := string(item.text) return &str -- cgit v1.2.3