mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2024-11-22 21:05:09 +00:00
Fix #162 - Ignore \e[K
This commit is contained in:
parent
9bba6bd172
commit
ce7d4a1c53
@ -18,7 +18,7 @@ BINDIR := ../bin
|
||||
|
||||
BINARY32 := fzf-$(GOOS)_386
|
||||
BINARY64 := fzf-$(GOOS)_amd64
|
||||
VERSION = $(shell fzf/$(BINARY64) --version)
|
||||
VERSION = $(shell fzf/$(BINARY64) --version | sed 's/-p[0-9]*//')
|
||||
RELEASE32 = fzf-$(VERSION)-$(GOOS)_386
|
||||
RELEASE64 = fzf-$(VERSION)-$(GOOS)_amd64
|
||||
|
||||
|
@ -33,7 +33,7 @@ func (s *ansiState) equals(t *ansiState) bool {
|
||||
var ansiRegex *regexp.Regexp
|
||||
|
||||
func init() {
|
||||
ansiRegex = regexp.MustCompile("\x1b\\[[0-9;]*m")
|
||||
ansiRegex = regexp.MustCompile("\x1b\\[[0-9;]*[mK]")
|
||||
}
|
||||
|
||||
func extractColor(str *string) (*string, []ansiOffset) {
|
||||
@ -87,6 +87,9 @@ func interpretCode(ansiCode string, prevState *ansiState) *ansiState {
|
||||
} else {
|
||||
state = &ansiState{prevState.fg, prevState.bg, prevState.bold}
|
||||
}
|
||||
if ansiCode[len(ansiCode)-1] == 'K' {
|
||||
return state
|
||||
}
|
||||
|
||||
ptr := &state.fg
|
||||
state256 := 0
|
||||
|
@ -53,6 +53,14 @@ func TestExtractColor(t *testing.T) {
|
||||
assert(offsets[0], 0, 6, -1, -1, true)
|
||||
})
|
||||
|
||||
src = "\x1b[1mhello \x1b[Kworld"
|
||||
check(func(offsets []ansiOffset) {
|
||||
if len(offsets) != 1 {
|
||||
t.Fail()
|
||||
}
|
||||
assert(offsets[0], 0, 11, -1, -1, true)
|
||||
})
|
||||
|
||||
src = "hello \x1b[34;45;1mworld"
|
||||
check(func(offsets []ansiOffset) {
|
||||
if len(offsets) != 1 {
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
)
|
||||
|
||||
// Current version
|
||||
const Version = "0.9.5"
|
||||
const Version = "0.9.5-p1"
|
||||
|
||||
// fzf events
|
||||
const (
|
||||
|
Loading…
Reference in New Issue
Block a user