Use matchaddpos() if possible

This commit is contained in:
haya14busa 2014-06-18 12:53:19 +09:00
parent e2aae85588
commit 57371aed8f
2 changed files with 11 additions and 3 deletions

View File

@ -985,9 +985,14 @@ function! s:PromptUser(groups) "{{{
else else
let _hl_group = g:EasyMotion_hl2_second_group_target let _hl_group = g:EasyMotion_hl2_second_group_target
endif endif
if exists('*matchaddpos')
call EasyMotion#highlight#add_pos_highlight(
\ line_num, col_num, _hl_group)
else
call EasyMotion#highlight#add_highlight( call EasyMotion#highlight#add_highlight(
\ '\%' . line_num . 'l' . target_col_regexp, \ '\%' . line_num . 'l' . target_col_regexp,
\ _hl_group) \ _hl_group)
endif
"}}} "}}}
" Add marker/target length difference for multibyte compensation " Add marker/target length difference for multibyte compensation

View File

@ -173,6 +173,9 @@ endfunction "}}}
function! EasyMotion#highlight#add_highlight(re, group) "{{{ function! EasyMotion#highlight#add_highlight(re, group) "{{{
call add(s:h.ids[a:group], matchadd(a:group, a:re, s:priorities[a:group])) call add(s:h.ids[a:group], matchadd(a:group, a:re, s:priorities[a:group]))
endfunction "}}} 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() "{{{ function! EasyMotion#highlight#attach_autocmd() "{{{
" Reference: https://github.com/justinmk/vim-sneak " Reference: https://github.com/justinmk/vim-sneak
augroup plugin-easymotion augroup plugin-easymotion