diff --git a/src/options.go b/src/options.go index 9b20e55a..bdd16e1c 100644 --- a/src/options.go +++ b/src/options.go @@ -648,14 +648,18 @@ func init() { // Backreferences are not supported. // "~!@#$%^&*;/|".each_char.map { |c| Regexp.escape(c) }.map { |c| "#{c}[^#{c}]*#{c}" }.join('|') executeRegexp = regexp.MustCompile( - `(?si):(execute(?:-multi|-silent)?|reload):.+|:(execute(?:-multi|-silent)?|reload)(\([^)]*\)|\[[^\]]*\]|~[^~]*~|![^!]*!|@[^@]*@|\#[^\#]*\#|\$[^\$]*\$|%[^%]*%|\^[^\^]*\^|&[^&]*&|\*[^\*]*\*|;[^;]*;|/[^/]*/|\|[^\|]*\|)`) + `(?si)[:+](execute(?:-multi|-silent)?|reload):.+|[:+](execute(?:-multi|-silent)?|reload)(\([^)]*\)|\[[^\]]*\]|~[^~]*~|![^!]*!|@[^@]*@|\#[^\#]*\#|\$[^\$]*\$|%[^%]*%|\^[^\^]*\^|&[^&]*&|\*[^\*]*\*|;[^;]*;|/[^/]*/|\|[^\|]*\|)`) } func parseKeymap(keymap map[int][]action, str string) { masked := executeRegexp.ReplaceAllStringFunc(str, func(src string) string { - prefix := ":execute" - if strings.HasPrefix(src, ":reload") { - prefix = ":reload" + symbol := ":" + if strings.HasPrefix(src, "+") { + symbol = "+" + } + prefix := symbol + "execute" + if strings.HasPrefix(src[1:], "reload") { + prefix = symbol + "reload" } else if src[len(prefix)] == '-' { c := src[len(prefix)+1] if c == 's' || c == 'S' { diff --git a/src/options_test.go b/src/options_test.go index 543bf570..5d35fb3e 100644 --- a/src/options_test.go +++ b/src/options_test.go @@ -243,7 +243,7 @@ func TestBind(t *testing.T) { check(tui.CtrlA, "", actBeginningOfLine) parseKeymap(keymap, "ctrl-a:kill-line,ctrl-b:toggle-sort+up+down,c:page-up,alt-z:page-down,"+ - "f1:execute(ls {})+abort,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 (,),[,],/,:,@,%,{};,"+ "x:Execute(foo+bar),X:execute/bar+baz/"+ ",,:abort,::accept,+:execute:++\nfoobar,Y:execute(baz)+up") @@ -253,7 +253,7 @@ func TestBind(t *testing.T) { check(tui.AltZ+',', "", actAbort) check(tui.AltZ+':', "", actAccept) check(tui.AltZ, "", actPageDown) - check(tui.F1, "ls {}", actExecute, actAbort) + check(tui.F1, "ls {+}", actExecute, actAbort, actExecute) check(tui.F2, "echo {}, {}, {}", actExecute) check(tui.F3, "echo '({})'", actExecute) check(tui.F4, "less {}", actExecute)