From e615600ff150e460a22d6a74da21a6df40d486fc Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Thu, 21 Nov 2019 23:06:14 +0900 Subject: [PATCH] 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 --- src/options.go | 6 +++++- src/options_test.go | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/options.go b/src/options.go index bdd16e1..bb7333c 100644 --- a/src/options.go +++ b/src/options.go @@ -809,7 +809,11 @@ func parseKeymap(keymap map[int][]action, str string) { default: t := isExecuteAction(specLower) if t == actIgnore { - errorExit("unknown action: " + spec) + if specIndex == 0 && specLower == "" { + actions = append(keymap[key], actions...) + } else { + errorExit("unknown action: " + spec) + } } else { var offset int switch t { diff --git a/src/options_test.go b/src/options_test.go index 5d35fb3..66d7c8f 100644 --- a/src/options_test.go +++ b/src/options_test.go @@ -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 {};,"+ "alt-a:execute-Multi@echo (,),[,],/,:,;,%,{}@,alt-b:execute;echo (,),[,],/,:,@,%,{};,"+ "x:Execute(foo+bar),X:execute/bar+baz/"+ + ",f1:+top,f1:+top"+ ",,:abort,::accept,+:execute:++\nfoobar,Y:execute(baz)+up") check(tui.CtrlA, "", actKillLine) check(tui.CtrlB, "", actToggleSort, actUp, actDown) @@ -253,7 +254,7 @@ func TestBind(t *testing.T) { check(tui.AltZ+',', "", actAbort) check(tui.AltZ+':', "", actAccept) 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.F3, "echo '({})'", actExecute) check(tui.F4, "less {}", actExecute)