diff options
| author | Junegunn Choi <junegunn.c@gmail.com> | 2019-11-12 22:45:25 +0900 |
|---|---|---|
| committer | Junegunn Choi <junegunn.c@gmail.com> | 2019-11-12 23:20:09 +0900 |
| commit | 751aa1944ae7fd1d8d1a12cc622f77cde160bb52 (patch) | |
| tree | db21f7426ca5383c1c4e0c551510c31a3e11b14f | |
| parent | 05b5f3f845a88e9b034f3302bb50672fc5b7f8c7 (diff) | |
| download | fzf-751aa1944ae7fd1d8d1a12cc622f77cde160bb52.tar.gz | |
Remove trailing whitespaces when using --with-nth
| -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) |
