From cf6b4f909f1b7a380bf8a05fc465f16b94e01663 Mon Sep 17 00:00:00 2001
From: Jerome Reybert <jreybert@gmail.com>
Date: Thu, 4 Oct 2018 00:35:13 +0200
Subject: [PATCH] Fix another escaping issue, with a global escape method ref
 #168

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.
---
 plugin/magit.vim | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/plugin/magit.vim b/plugin/magit.vim
index 7b2e775..ec3a3b0 100644
--- a/plugin/magit.vim
+++ b/plugin/magit.vim
@@ -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
-- 
GitLab