diff options
author | Bram Moolenaar <Bram@vim.org> | 2014-06-17 17:48:32 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2014-06-17 17:48:32 +0200 |
commit | b3414595c713ca161f082776f89417faddec7d2d (patch) | |
tree | 5f03f600e04a2455ce84033c49db30b680d571c6 /runtime/plugin | |
parent | ec1561cac59006213dd5405d164a94dc7d002806 (diff) |
updated for version 7.4.330v7.4.330
Problem: Using a regexp pattern to highlight a specific position can be
slow.
Solution: Add matchaddpos() to highlight specific positions efficiently.
(Alexey Radkov)
Diffstat (limited to 'runtime/plugin')
-rw-r--r-- | runtime/plugin/matchparen.vim | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/runtime/plugin/matchparen.vim b/runtime/plugin/matchparen.vim index 0fdfef164a..b490f45ebb 100644 --- a/runtime/plugin/matchparen.vim +++ b/runtime/plugin/matchparen.vim @@ -1,6 +1,6 @@ " Vim plugin for showing matching parens " Maintainer: Bram Moolenaar <Bram@vim.org> -" Last Change: 2013 May 08 +" Last Change: 2014 Jun 17 " Exit quickly when: " - this plugin was already loaded (or disabled) @@ -39,7 +39,7 @@ set cpo-=C function! s:Highlight_Matching_Pair() " Remove any previous match. if exists('w:paren_hl_on') && w:paren_hl_on - 3match none + silent! call matchdelete(3) let w:paren_hl_on = 0 endif @@ -152,14 +152,18 @@ function! s:Highlight_Matching_Pair() " If a match is found setup match highlighting. if m_lnum > 0 && m_lnum >= stoplinetop && m_lnum <= stoplinebottom - exe '3match MatchParen /\(\%' . c_lnum . 'l\%' . (c_col - before) . - \ 'c\)\|\(\%' . m_lnum . 'l\%' . m_col . 'c\)/' + if exists('*matchaddpos') + call matchaddpos('MatchParen', [[c_lnum, c_col - before], [m_lnum, m_col]], 10, 3) + else + exe '3match MatchParen /\(\%' . c_lnum . 'l\%' . (c_col - before) . + \ 'c\)\|\(\%' . m_lnum . 'l\%' . m_col . 'c\)/' + endif let w:paren_hl_on = 1 endif endfunction " Define commands that will disable and enable the plugin. -command! NoMatchParen windo 3match none | unlet! g:loaded_matchparen | +command! NoMatchParen windo silent! call matchdelete(3) | unlet! g:loaded_matchparen | \ au! matchparen command! DoMatchParen runtime plugin/matchparen.vim | windo doau CursorMoved |