Skip to content

Commit

Permalink
Fix another escaping issue, with a global escape method ref #168
Browse files Browse the repository at this point in the history
Another issue with escape problem. It was finally the same culprit.

match() function take a pattern as a paramter. If a:selection[0], the
hunk title, contains any regex special character, it goes wild.

It seems safer to escape with special character \V (very nomagic)
instead of adding regularly special characters to escape() function.
  • Loading branch information
jreybert committed Oct 3, 2018
1 parent 16d9775 commit cf6b4f9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion plugin/magit.vim
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,7 @@ function! magit#stage_block(selection, discard) abort
" find current hunk position in file matching against current selection
" header
try
let hunk_id = match(map(deepcopy(file.get_hunks()), 'v:val.header'), escape(a:selection[0], '~*'))
let hunk_id = match(map(deepcopy(file.get_hunks()), 'v:val.header'), "\\V" . a:selection[0])
catch /^Vim\%((\a\+)\)\=:E874/
echoerr "Escape issue with '" . a:selection[0] ."'"
return
Expand Down

0 comments on commit cf6b4f9

Please sign in to comment.