From 2da32565a73c0a9ab25d4fd9b0f6626336202d07 Mon Sep 17 00:00:00 2001 From: Peter Odding Date: Sun, 6 Jun 2010 17:14:37 +0200 Subject: [PATCH] Bug fix: Escape ~ in tag search patterns There's probably more characters I'm supposed to escape. Ideally I would just prefix \V to every search pattern like the Vim documentation describes but I couldn't get this to work consistently :-( --- autoload.vim | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/autoload.vim b/autoload.vim index d2b85e5..0bc0e5c 100644 --- a/autoload.vim +++ b/autoload.vim @@ -69,7 +69,12 @@ function! s:pattern_to_lnum(entry, pathname) " {{{2 let contents = s:cached_contents[a:pathname] endif let pattern = substitute(a:entry.cmd, '^/\(.*\)/$', '\1', '') - let index = match(contents, pattern) + let pattern = substitute(pattern, '\~', '\\~', 'g') + try + let index = match(contents, pattern) + catch + throw "Failed pattern: " . string(pattern) + endtry if index >= 0 let lnum = index + 1 let a:entry.cmd = string(lnum)