From 9d7511426c6e773199d97cc25f22340a9768b34f Mon Sep 17 00:00:00 2001 From: thingmarius Date: Thu, 12 Jan 2017 12:00:46 +0200 Subject: [PATCH] Excape backslashes in filepaths for regex matching Highlighting failed on Windows because the file paths contain backslashes. This could potentially fail on *nix systems as well, if the paths contained backslashes. Fixed by enabling very nomagic mode and escaping backslashes: path_pattern = '\V' . escape(path, '\') --- ftplugin/python/coveragepy.vim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ftplugin/python/coveragepy.vim b/ftplugin/python/coveragepy.vim index 1b40752..db91726 100755 --- a/ftplugin/python/coveragepy.vim +++ b/ftplugin/python/coveragepy.vim @@ -108,7 +108,9 @@ function! s:HighlightMissing() abort let current_buffer = matchlist(expand("%:p"), '\v(.*)(.py)')[1] for path in keys(g:coveragepy_session_map) - if (current_buffer =~ path) || (current_buffer_py =~ path) + " escape path to use it as a regex pattern + let path_pattern = '\V' . escape(path, '\') + if (current_buffer =~ path_pattern) || (current_buffer_py =~ path_pattern) for position in g:coveragepy_session_map[path] execute(":sign place ". position ." line=". position ." name=uncovered buffer=".bufnr("%")) endfor