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