From 57371aed8fa5354c6a7f6389d96c083a74b93eeb Mon Sep 17 00:00:00 2001 From: haya14busa Date: Wed, 18 Jun 2014 12:53:19 +0900 Subject: [PATCH] Use matchaddpos() if possible --- autoload/EasyMotion.vim | 11 ++++++++--- autoload/EasyMotion/highlight.vim | 3 +++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/autoload/EasyMotion.vim b/autoload/EasyMotion.vim index d5eff99..17c4e16 100644 --- a/autoload/EasyMotion.vim +++ b/autoload/EasyMotion.vim @@ -985,9 +985,14 @@ function! s:PromptUser(groups) "{{{ else let _hl_group = g:EasyMotion_hl2_second_group_target endif - call EasyMotion#highlight#add_highlight( - \ '\%' . line_num . 'l' . target_col_regexp, - \ _hl_group) + if exists('*matchaddpos') + call EasyMotion#highlight#add_pos_highlight( + \ line_num, col_num, _hl_group) + else + call EasyMotion#highlight#add_highlight( + \ '\%' . line_num . 'l' . target_col_regexp, + \ _hl_group) + endif "}}} " Add marker/target length difference for multibyte compensation diff --git a/autoload/EasyMotion/highlight.vim b/autoload/EasyMotion/highlight.vim index f6327f1..543e091 100644 --- a/autoload/EasyMotion/highlight.vim +++ b/autoload/EasyMotion/highlight.vim @@ -173,6 +173,9 @@ endfunction "}}} function! EasyMotion#highlight#add_highlight(re, group) "{{{ call add(s:h.ids[a:group], matchadd(a:group, a:re, s:priorities[a:group])) endfunction "}}} +function! EasyMotion#highlight#add_pos_highlight(line_num, col_num, group) "{{{ + call add(s:h.ids[a:group], matchaddpos(a:group, [[a:line_num, a:col_num]], s:priorities[a:group])) +endfunction "}}} function! EasyMotion#highlight#attach_autocmd() "{{{ " Reference: https://github.com/justinmk/vim-sneak augroup plugin-easymotion