]> granicus.if.org Git - vim/commitdiff
patch 8.1.0143: matchit and matchparen don't handle E363 v8.1.0143
authorBram Moolenaar <Bram@vim.org>
Tue, 3 Jul 2018 16:18:23 +0000 (18:18 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 3 Jul 2018 16:18:23 +0000 (18:18 +0200)
Problem:    Matchit and matchparen don't handle E363.
Solution:   Catch the E363 error. (Christian Brabandt)

runtime/pack/dist/opt/matchit/plugin/matchit.vim
runtime/plugin/matchparen.vim
src/version.c

index 5e9df89c474f7b977dec103d01d65675646fee12..6f3c0f894266666fbca7eb419eb21a1229e70b60 100644 (file)
@@ -1,5 +1,5 @@
 "  matchit.vim: (global plugin) Extended "%" matching
-"  Last Change: 2017 Sep 15
+"  Last Change: 2018 Jul 3 by Christian Brabandt
 "  Maintainer:  Benji Fisher PhD   <benji@member.AMS.org>
 "  Version:     1.13.3, for Vim 6.3+
 "              Fix from Fernando Torres included.
@@ -272,7 +272,7 @@ function! s:Match_wrapper(word, forward, mode) range
   "   execute "normal!" . curcol . "l"
   " endif
   if skip =~ 'synID' && !(has("syntax") && exists("g:syntax_on"))
-    let skip = "0"
+    let skip = '0'
   else
     execute "if " . skip . "| let skip = '0' | endif"
   endif
@@ -719,10 +719,16 @@ fun! s:MultiMatch(spflag, mode)
   let openpat = substitute(openpat, ',', '\\|', 'g')
   let closepat = substitute(close, '\(\\\@<!\(\\\\\)*\)\@<=\\(', '\\%(', 'g')
   let closepat = substitute(closepat, ',', '\\|', 'g')
+
   if skip =~ 'synID' && !(has("syntax") && exists("g:syntax_on"))
     let skip = '0'
   else
-    execute "if " . skip . "| let skip = '0' | endif"
+    try
+      execute "if " . skip . "| let skip = '0' | endif"
+    catch /^Vim\%((\a\+)\)\=:E363/
+      " We won't find anything, so skip searching, should keep Vim responsive.
+      return
+    endtry
   endif
   mark '
   while level
index d53fb22df023fd87b1c1f642c99de6b9cbe38c31..65b9fe57bf31aac73d6d5905a9f5e7b500fe7a52 100644 (file)
@@ -1,6 +1,6 @@
 " Vim plugin for showing matching parens
 " Maintainer:  Bram Moolenaar <Bram@vim.org>
-" Last Change: 2018 Jun 23
+" Last Change: 2018 Ju3
 
 " Exit quickly when:
 " - this plugin was already loaded (or disabled)
@@ -103,18 +103,28 @@ function! s:Highlight_Matching_Pair()
     call cursor(c_lnum, c_col - before)
   endif
 
-  " Build an expression that detects whether the current cursor position is in
-  " certain syntax types (string, comment, etc.), for use as searchpairpos()'s
-  " skip argument.
-  " We match "escape" for special items, such as lispEscapeSpecial.
-  let s_skip = '!empty(filter(map(synstack(line("."), col(".")), ''synIDattr(v:val, "name")''), ' .
+  if !has("syntax") || !exists("g:syntax_on")
+    let s_skip = "0"
+  else
+    " Build an expression that detects whether the current cursor position is
+    " in certain syntax types (string, comment, etc.), for use as
+    " searchpairpos()'s skip argument.
+    " We match "escape" for special items, such as lispEscapeSpecial.
+    let s_skip = '!empty(filter(map(synstack(line("."), col(".")), ''synIDattr(v:val, "name")''), ' .
        \ '''v:val =~? "string\\|character\\|singlequote\\|escape\\|comment"''))'
-  " If executing the expression determines that the cursor is currently in
-  " one of the syntax types, then we want searchpairpos() to find the pair
-  " within those syntax types (i.e., not skip).  Otherwise, the cursor is
-  " outside of the syntax types and s_skip should keep its value so we skip any
-  " matching pair inside the syntax types.
-  execute 'if' s_skip '| let s_skip = "0" | endif'
+    " If executing the expression determines that the cursor is currently in
+    " one of the syntax types, then we want searchpairpos() to find the pair
+    " within those syntax types (i.e., not skip).  Otherwise, the cursor is
+    " outside of the syntax types and s_skip should keep its value so we skip
+    " any matching pair inside the syntax types.
+    " Catch if this throws E363: pattern uses more memory than 'maxmempattern'.
+    try
+      execute 'if ' . s_skip . ' | let s_skip = "0" | endif'
+    catch /^Vim\%((\a\+)\)\=:E363/
+      " We won't find anything, so skip searching, should keep Vim responsive.
+      return
+    endtry
+  endif
 
   " Limit the search to lines visible in the window.
   let stoplinebottom = line('w$')
index 8efe57ef9c2d06708d92f8b75d21df1e28e32f93..38c77103b6ffa11bd275e158361c9a3013bf2738 100644 (file)
@@ -789,6 +789,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    143,
 /**/
     142,
 /**/