comparison runtime/plugin/matchparen.vim @ 14254:1cfeee3ba4cd v8.1.0143

patch 8.1.0143: matchit and matchparen don't handle E363 commit https://github.com/vim/vim/commit/3d1d6475f9665660c80cc53a7da2d5450b8b8d08 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jul 3 18:18:23 2018 +0200 patch 8.1.0143: matchit and matchparen don't handle E363 Problem: Matchit and matchparen don't handle E363. Solution: Catch the E363 error. (Christian Brabandt)
author Christian Brabandt <cb@256bit.org>
date Tue, 03 Jul 2018 18:30:06 +0200
parents 4543777545a3
children 1cd44535be32
comparison
equal deleted inserted replaced
14253:a0586da3a85b 14254:1cfeee3ba4cd
1 " Vim plugin for showing matching parens 1 " Vim plugin for showing matching parens
2 " Maintainer: Bram Moolenaar <Bram@vim.org> 2 " Maintainer: Bram Moolenaar <Bram@vim.org>
3 " Last Change: 2018 Jun 23 3 " Last Change: 2018 Jul 3
4 4
5 " Exit quickly when: 5 " Exit quickly when:
6 " - this plugin was already loaded (or disabled) 6 " - this plugin was already loaded (or disabled)
7 " - when 'compatible' is set 7 " - when 'compatible' is set
8 " - the "CursorMoved" autocmd event is not available. 8 " - the "CursorMoved" autocmd event is not available.
101 let save_cursor = winsaveview() 101 let save_cursor = winsaveview()
102 endif 102 endif
103 call cursor(c_lnum, c_col - before) 103 call cursor(c_lnum, c_col - before)
104 endif 104 endif
105 105
106 " Build an expression that detects whether the current cursor position is in 106 if !has("syntax") || !exists("g:syntax_on")
107 " certain syntax types (string, comment, etc.), for use as searchpairpos()'s 107 let s_skip = "0"
108 " skip argument. 108 else
109 " We match "escape" for special items, such as lispEscapeSpecial. 109 " Build an expression that detects whether the current cursor position is
110 let s_skip = '!empty(filter(map(synstack(line("."), col(".")), ''synIDattr(v:val, "name")''), ' . 110 " in certain syntax types (string, comment, etc.), for use as
111 " searchpairpos()'s skip argument.
112 " We match "escape" for special items, such as lispEscapeSpecial.
113 let s_skip = '!empty(filter(map(synstack(line("."), col(".")), ''synIDattr(v:val, "name")''), ' .
111 \ '''v:val =~? "string\\|character\\|singlequote\\|escape\\|comment"''))' 114 \ '''v:val =~? "string\\|character\\|singlequote\\|escape\\|comment"''))'
112 " If executing the expression determines that the cursor is currently in 115 " If executing the expression determines that the cursor is currently in
113 " one of the syntax types, then we want searchpairpos() to find the pair 116 " one of the syntax types, then we want searchpairpos() to find the pair
114 " within those syntax types (i.e., not skip). Otherwise, the cursor is 117 " within those syntax types (i.e., not skip). Otherwise, the cursor is
115 " outside of the syntax types and s_skip should keep its value so we skip any 118 " outside of the syntax types and s_skip should keep its value so we skip
116 " matching pair inside the syntax types. 119 " any matching pair inside the syntax types.
117 execute 'if' s_skip '| let s_skip = "0" | endif' 120 " Catch if this throws E363: pattern uses more memory than 'maxmempattern'.
121 try
122 execute 'if ' . s_skip . ' | let s_skip = "0" | endif'
123 catch /^Vim\%((\a\+)\)\=:E363/
124 " We won't find anything, so skip searching, should keep Vim responsive.
125 return
126 endtry
127 endif
118 128
119 " Limit the search to lines visible in the window. 129 " Limit the search to lines visible in the window.
120 let stoplinebottom = line('w$') 130 let stoplinebottom = line('w$')
121 let stoplinetop = line('w0') 131 let stoplinetop = line('w0')
122 if i % 2 == 0 132 if i % 2 == 0