From 8e1beef8770c44499d6ec8c6db9aebd71eb564cd Mon Sep 17 00:00:00 2001 From: Jerome Reybert <jreybert@gmail.com> Date: Wed, 3 Oct 2018 23:33:02 +0200 Subject: [PATCH] tild character must be escaped in hunk title ref #156 vimagit may want to search hunk position, based on hunk title. When a hunk title has a '~' in it, the character make the search crash. It must be escaped. Finnally, after almost one year of open issue and several issue contributors, I got it, thanks to akrejczinger and its docker image. The reason I was unable to reproduce this issue is maybe that all the vim and nvim version I used were built with another regex engine. --- plugin/magit.vim | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugin/magit.vim b/plugin/magit.vim index 46845ac..7b2e775 100644 --- a/plugin/magit.vim +++ b/plugin/magit.vim @@ -964,7 +964,13 @@ function! magit#stage_block(selection, discard) abort " find current hunk position in file matching against current selection " header - let hunk_id = match(map(deepcopy(file.get_hunks()), 'v:val.header'), escape(a:selection[0], '*')) + try + let hunk_id = match(map(deepcopy(file.get_hunks()), 'v:val.header'), escape(a:selection[0], '~*')) + catch /^Vim\%((\a\+)\)\=:E874/ + echoerr "Escape issue with '" . a:selection[0] ."'" + return + endtry + if ( a:discard == 0 ) if ( section == 'unstaged' ) -- GitLab