Mercurial > vim
diff runtime/plugin/matchparen.vim @ 5979:f9fa2e506b9f v7.4.330
updated for version 7.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)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Tue, 17 Jun 2014 17:48:32 +0200 |
parents | eb6ab7e78925 |
children | 0efec12f52ac |
line wrap: on
line diff
--- 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