summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2015-06-15 23:11:22 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2015-06-15 23:11:22 +0900
commit794ad5785ddd96e65e71767be2de201d0b154df2 (patch)
treefaee48efe460eedd4b457abff1525420f03c9434
parentfa5b58968e67a7f046d67554174a1923cfb30ea9 (diff)
Fix `.` to match newlines as well (#265)
-rw-r--r--src/options.go2
-rw-r--r--src/options_test.go4
2 files changed, 3 insertions, 3 deletions
diff --git a/src/options.go b/src/options.go
index 25a87ac7..7ecf7649 100644
--- a/src/options.go
+++ b/src/options.go
@@ -412,7 +412,7 @@ func parseKeymap(keymap map[int]actionType, execmap map[int]string, toggleSort b
// Backreferences are not supported.
// "~!@#$%^&*:;/|".each_char.map { |c| Regexp.escape(c) }.map { |c| "#{c}[^#{c}]*#{c}" }.join('|')
executeRegexp = regexp.MustCompile(
- ":execute=.*|:execute(\\([^)]*\\)|\\[[^\\]]*\\]|~[^~]*~|![^!]*!|@[^@]*@|\\#[^\\#]*\\#|\\$[^\\$]*\\$|%[^%]*%|\\^[^\\^]*\\^|&[^&]*&|\\*[^\\*]*\\*|:[^:]*:|;[^;]*;|/[^/]*/|\\|[^\\|]*\\|)")
+ "(?s):execute=.*|:execute(\\([^)]*\\)|\\[[^\\]]*\\]|~[^~]*~|![^!]*!|@[^@]*@|\\#[^\\#]*\\#|\\$[^\\$]*\\$|%[^%]*%|\\^[^\\^]*\\^|&[^&]*&|\\*[^\\*]*\\*|:[^:]*:|;[^;]*;|/[^/]*/|\\|[^\\|]*\\|)")
}
masked := executeRegexp.ReplaceAllStringFunc(str, func(src string) string {
return ":execute(" + strings.Repeat(" ", len(src)-10) + ")"
diff --git a/src/options_test.go b/src/options_test.go
index 162b8e48..3c33ef47 100644
--- a/src/options_test.go
+++ b/src/options_test.go
@@ -164,7 +164,7 @@ func TestBind(t *testing.T) {
"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 {}:,"+
"alt-a:execute@echo (,),[,],/,:,;,%,{}@,alt-b:execute;echo (,),[,],/,:,@,%,{};"+
- ",X:execute=foobar,Y:execute(baz)")
+ ",X:execute=\nfoobar,Y:execute(baz)")
if !toggleSort {
t.Errorf("toggleSort not set")
}
@@ -182,7 +182,7 @@ func TestBind(t *testing.T) {
checkString("less {}", execmap[curses.F4])
checkString("echo (,),[,],/,:,;,%,{}", execmap[curses.AltA])
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{'~', '!', '@', '#', '$', '%', '^', '&', '*', '|', ':', ';', '/'} {
keymap, execmap, toggleSort =