mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2025-01-15 11:46:58 +00:00
Compare commits
2 Commits
93c0299606
...
14ef8e8051
Author | SHA1 | Date | |
---|---|---|---|
|
14ef8e8051 | ||
|
cc1d9f124e |
@ -76,8 +76,8 @@ function fzf_key_bindings
|
||||
set -l line 0
|
||||
for i in (builtin history -z --reverse | string split0)
|
||||
set line (math $line + 1)
|
||||
string escape -n -- $line\t$i
|
||||
end | string join0 | string replace -a '\n' '\n\t' | string unescape -n | eval (__fzfcmd) --tac --read0 --print0 -q '(commandline)' | string replace -r '^\d*\t' '' | read -lz result
|
||||
string escape -n -- $line\t(string replace -a -- \n \n\t $i | string collect)
|
||||
end | string join0 | string unescape -n | eval (__fzfcmd) --tac --read0 --print0 -q '(commandline)' | string replace -r '^\d*\t' '' | read -lz result
|
||||
and commandline -- $result
|
||||
end
|
||||
else
|
||||
|
16
src/ansi.go
16
src/ansi.go
@ -310,20 +310,15 @@ func extractColor(str string, state *ansiState, proc func(string, *ansiState) bo
|
||||
return trimmed, nil, state
|
||||
}
|
||||
|
||||
func parseAnsiCode(s string, delimiter byte) (int, byte, string) {
|
||||
func parseAnsiCode(s string) (int, string) {
|
||||
var remaining string
|
||||
var i int
|
||||
if delimiter == 0 {
|
||||
// Faster than strings.IndexAny(";:")
|
||||
i = strings.IndexByte(s, ';')
|
||||
if i < 0 {
|
||||
i = strings.IndexByte(s, ':')
|
||||
}
|
||||
} else {
|
||||
i = strings.IndexByte(s, delimiter)
|
||||
}
|
||||
if i >= 0 {
|
||||
delimiter = s[i]
|
||||
remaining = s[i+1:]
|
||||
s = s[:i]
|
||||
}
|
||||
@ -335,14 +330,14 @@ func parseAnsiCode(s string, delimiter byte) (int, byte, string) {
|
||||
for _, ch := range stringBytes(s) {
|
||||
ch -= '0'
|
||||
if ch > 9 {
|
||||
return -1, delimiter, remaining
|
||||
return -1, remaining
|
||||
}
|
||||
code = code*10 + int(ch)
|
||||
}
|
||||
return code, delimiter, remaining
|
||||
return code, remaining
|
||||
}
|
||||
|
||||
return -1, delimiter, remaining
|
||||
return -1, remaining
|
||||
}
|
||||
|
||||
func interpretCode(ansiCode string, prevState *ansiState) ansiState {
|
||||
@ -378,11 +373,10 @@ func interpretCode(ansiCode string, prevState *ansiState) ansiState {
|
||||
state256 := 0
|
||||
ptr := &state.fg
|
||||
|
||||
var delimiter byte
|
||||
count := 0
|
||||
for len(ansiCode) != 0 {
|
||||
var num int
|
||||
if num, delimiter, ansiCode = parseAnsiCode(ansiCode, delimiter); num != -1 {
|
||||
if num, ansiCode = parseAnsiCode(ansiCode); num != -1 {
|
||||
count++
|
||||
switch state256 {
|
||||
case 0:
|
||||
|
@ -381,7 +381,7 @@ func TestParseAnsiCode(t *testing.T) {
|
||||
{"-2", "", -1},
|
||||
}
|
||||
for _, x := range tests {
|
||||
n, _, s := parseAnsiCode(x.In, 0)
|
||||
n, s := parseAnsiCode(x.In)
|
||||
if n != x.N || s != x.Exp {
|
||||
t.Fatalf("%q: got: (%d %q) want: (%d %q)", x.In, n, s, x.N, x.Exp)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user