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)
This commit is contained in:
@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user