m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-18 00:03:39 -05:00

Should not strip ANSI codes when --ansi is not set

This commit is contained in:
Junegunn Choi
2015-08-28 21:23:10 +09:00
parent 698e8008df
commit 90b0cd44ac
4 changed files with 22 additions and 10 deletions

View File

@@ -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