Skip to content

Commit

Permalink
tild character must be escaped in hunk title ref #156
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jreybert committed Oct 3, 2018
1 parent f32316d commit 8e1beef
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion plugin/magit.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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' )
Expand Down

0 comments on commit 8e1beef

Please sign in to comment.