mirror of
https://github.com/junegunn/fzf
synced 2024-11-10 13:10:44 +00:00
Fix .
to match newlines as well (#265)
This commit is contained in:
parent
fa5b58968e
commit
794ad5785d
@ -412,7 +412,7 @@ func parseKeymap(keymap map[int]actionType, execmap map[int]string, toggleSort b
|
|||||||
// Backreferences are not supported.
|
// Backreferences are not supported.
|
||||||
// "~!@#$%^&*:;/|".each_char.map { |c| Regexp.escape(c) }.map { |c| "#{c}[^#{c}]*#{c}" }.join('|')
|
// "~!@#$%^&*:;/|".each_char.map { |c| Regexp.escape(c) }.map { |c| "#{c}[^#{c}]*#{c}" }.join('|')
|
||||||
executeRegexp = regexp.MustCompile(
|
executeRegexp = regexp.MustCompile(
|
||||||
":execute=.*|:execute(\\([^)]*\\)|\\[[^\\]]*\\]|~[^~]*~|![^!]*!|@[^@]*@|\\#[^\\#]*\\#|\\$[^\\$]*\\$|%[^%]*%|\\^[^\\^]*\\^|&[^&]*&|\\*[^\\*]*\\*|:[^:]*:|;[^;]*;|/[^/]*/|\\|[^\\|]*\\|)")
|
"(?s):execute=.*|:execute(\\([^)]*\\)|\\[[^\\]]*\\]|~[^~]*~|![^!]*!|@[^@]*@|\\#[^\\#]*\\#|\\$[^\\$]*\\$|%[^%]*%|\\^[^\\^]*\\^|&[^&]*&|\\*[^\\*]*\\*|:[^:]*:|;[^;]*;|/[^/]*/|\\|[^\\|]*\\|)")
|
||||||
}
|
}
|
||||||
masked := executeRegexp.ReplaceAllStringFunc(str, func(src string) string {
|
masked := executeRegexp.ReplaceAllStringFunc(str, func(src string) string {
|
||||||
return ":execute(" + strings.Repeat(" ", len(src)-10) + ")"
|
return ":execute(" + strings.Repeat(" ", len(src)-10) + ")"
|
||||||
|
@ -164,7 +164,7 @@ func TestBind(t *testing.T) {
|
|||||||
"ctrl-a:kill-line,ctrl-b:toggle-sort,c:page-up,alt-z:page-down,"+
|
"ctrl-a:kill-line,ctrl-b:toggle-sort,c:page-up,alt-z:page-down,"+
|
||||||
"f1:execute(ls {}),f2:execute/echo {}, {}, {}/,f3:execute[echo '({})'],f4:execute:less {}:,"+
|
"f1:execute(ls {}),f2:execute/echo {}, {}, {}/,f3:execute[echo '({})'],f4:execute:less {}:,"+
|
||||||
"alt-a:execute@echo (,),[,],/,:,;,%,{}@,alt-b:execute;echo (,),[,],/,:,@,%,{};"+
|
"alt-a:execute@echo (,),[,],/,:,;,%,{}@,alt-b:execute;echo (,),[,],/,:,@,%,{};"+
|
||||||
",X:execute=foobar,Y:execute(baz)")
|
",X:execute=\nfoobar,Y:execute(baz)")
|
||||||
if !toggleSort {
|
if !toggleSort {
|
||||||
t.Errorf("toggleSort not set")
|
t.Errorf("toggleSort not set")
|
||||||
}
|
}
|
||||||
@ -182,7 +182,7 @@ func TestBind(t *testing.T) {
|
|||||||
checkString("less {}", execmap[curses.F4])
|
checkString("less {}", execmap[curses.F4])
|
||||||
checkString("echo (,),[,],/,:,;,%,{}", execmap[curses.AltA])
|
checkString("echo (,),[,],/,:,;,%,{}", execmap[curses.AltA])
|
||||||
checkString("echo (,),[,],/,:,@,%,{}", execmap[curses.AltB])
|
checkString("echo (,),[,],/,:,@,%,{}", execmap[curses.AltB])
|
||||||
checkString("foobar,Y:execute(baz)", execmap[curses.AltZ+'X'])
|
checkString("\nfoobar,Y:execute(baz)", execmap[curses.AltZ+'X'])
|
||||||
|
|
||||||
for idx, char := range []rune{'~', '!', '@', '#', '$', '%', '^', '&', '*', '|', ':', ';', '/'} {
|
for idx, char := range []rune{'~', '!', '@', '#', '$', '%', '^', '&', '*', '|', ':', ';', '/'} {
|
||||||
keymap, execmap, toggleSort =
|
keymap, execmap, toggleSort =
|
||||||
|
Loading…
Reference in New Issue
Block a user