Allow action composition over multiple --bind

# Note + prefix in the second bind expression
  fzf --bind u:up --bind u:+up
  fzf --bind u:up+up
This commit is contained in:
Junegunn Choi 2019-11-21 23:06:14 +09:00
parent 60465c4664
commit e615600ff1
2 changed files with 7 additions and 2 deletions

View File

@ -809,7 +809,11 @@ func parseKeymap(keymap map[int][]action, str string) {
default: default:
t := isExecuteAction(specLower) t := isExecuteAction(specLower)
if t == actIgnore { if t == actIgnore {
if specIndex == 0 && specLower == "" {
actions = append(keymap[key], actions...)
} else {
errorExit("unknown action: " + spec) errorExit("unknown action: " + spec)
}
} else { } else {
var offset int var offset int
switch t { switch t {

View File

@ -246,6 +246,7 @@ func TestBind(t *testing.T) {
"f1:execute(ls {+})+abort+execute(echo {+})+select-all,f2:execute/echo {}, {}, {}/,f3:execute[echo '({})'],f4:execute;less {};,"+ "f1:execute(ls {+})+abort+execute(echo {+})+select-all,f2:execute/echo {}, {}, {}/,f3:execute[echo '({})'],f4:execute;less {};,"+
"alt-a:execute-Multi@echo (,),[,],/,:,;,%,{}@,alt-b:execute;echo (,),[,],/,:,@,%,{};,"+ "alt-a:execute-Multi@echo (,),[,],/,:,;,%,{}@,alt-b:execute;echo (,),[,],/,:,@,%,{};,"+
"x:Execute(foo+bar),X:execute/bar+baz/"+ "x:Execute(foo+bar),X:execute/bar+baz/"+
",f1:+top,f1:+top"+
",,:abort,::accept,+:execute:++\nfoobar,Y:execute(baz)+up") ",,:abort,::accept,+:execute:++\nfoobar,Y:execute(baz)+up")
check(tui.CtrlA, "", actKillLine) check(tui.CtrlA, "", actKillLine)
check(tui.CtrlB, "", actToggleSort, actUp, actDown) check(tui.CtrlB, "", actToggleSort, actUp, actDown)
@ -253,7 +254,7 @@ func TestBind(t *testing.T) {
check(tui.AltZ+',', "", actAbort) check(tui.AltZ+',', "", actAbort)
check(tui.AltZ+':', "", actAccept) check(tui.AltZ+':', "", actAccept)
check(tui.AltZ, "", actPageDown) check(tui.AltZ, "", actPageDown)
check(tui.F1, "ls {+}", actExecute, actAbort, actExecute) check(tui.F1, "ls {+}", actExecute, actAbort, actExecute, actSelectAll, actTop, actTop)
check(tui.F2, "echo {}, {}, {}", actExecute) check(tui.F2, "echo {}, {}, {}", actExecute)
check(tui.F3, "echo '({})'", actExecute) check(tui.F3, "echo '({})'", actExecute)
check(tui.F4, "less {}", actExecute) check(tui.F4, "less {}", actExecute)