From ad3b366c8250a6f3c7ac699bc4b0f2e613286089 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Fri, 17 May 2013 18:14:19 +0200 Subject: Update runtime files. --- runtime/plugin/matchparen.vim | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'runtime/plugin/matchparen.vim') diff --git a/runtime/plugin/matchparen.vim b/runtime/plugin/matchparen.vim index 2965ad147..0fdfef164 100644 --- a/runtime/plugin/matchparen.vim +++ b/runtime/plugin/matchparen.vim @@ -1,6 +1,6 @@ " Vim plugin for showing matching parens " Maintainer: Bram Moolenaar -" Last Change: 2013 Mar 19 +" Last Change: 2013 May 08 " Exit quickly when: " - this plugin was already loaded (or disabled) @@ -11,6 +11,13 @@ if exists("g:loaded_matchparen") || &cp || !exists("##CursorMoved") endif let g:loaded_matchparen = 1 +if !exists("g:matchparen_timeout") + let g:matchparen_timeout = 300 +endif +if !exists("g:matchparen_insert_timeout") + let g:matchparen_insert_timeout = 60 +endif + augroup matchparen " Replace all matchparen autocommands autocmd! CursorMoved,CursorMovedI,WinEnter * call s:Highlight_Matching_Pair() @@ -99,10 +106,15 @@ function! s:Highlight_Matching_Pair() let stopline = stoplinetop endif + " Limit the search time to 300 msec to avoid a hang on very long lines. + " This fails when a timeout is not supported. + if mode() == 'i' || mode() == 'R' + let timeout = exists("b:matchparen_insert_timeout") ? b:matchparen_insert_timeout : g:matchparen_insert_timeout + else + let timeout = exists("b:matchparen_timeout") ? b:matchparen_timeout : g:matchparen_timeout + endif try - " Limit the search time to 300 msec to avoid a hang on very long lines. - " This fails when a timeout is not supported. - let [m_lnum, m_col] = searchpairpos(c, '', c2, s_flags, s_skip, stopline, 300) + let [m_lnum, m_col] = searchpairpos(c, '', c2, s_flags, s_skip, stopline, timeout) catch /E118/ " Can't use the timeout, restrict the stopline a bit more to avoid taking " a long time on closed folds and long lines. -- cgit v1.2.3