Closed nkouevda closed 9 years ago
A potential fix would be to surround pat
with \(
and \)
(note that \%(
would not work):
@@ -341 +341 @@ function! s:highlight_current_match(...)
- silent! call s:matchadd(group, s:prefix_for(pat, highlight_all) . pat)
+ silent! call s:matchadd(group, s:prefix_for(pat, highlight_all) . '\(' . pat . '\)')
This solves the issues I mentioned above, but introduces others (e.g. references like \1
break).
A branch separator would be better:
@@ -341 +341 @@ function! s:highlight_current_match(...)
- silent! call s:matchadd(group, s:prefix_for(pat, highlight_all) . pat)
+ silent! call s:matchadd(group, s:prefix_for(pat, highlight_all) . '\&' . pat)
I haven't yet found any downsides to this approach. What do you think @junegunn?
Superb, thanks! I'll apply your patch.
It is necessary for
s:highlight_current_match
to prefixpat
withs:prefix_for(pat, highlight_all)
before callings:matchadd
, but this has some unintended side effects:pat
is*
, then the resultant pattern is something like\c\%1l\%1c*
, so the*
becomes a quantifier.pat
begins with^
, the resultant pattern no longer matches at the beginning of the line.