Bram,
Can you please squash the following patch in?
Best,
Christian
--
Alle Menschen sind klug; die einen vorher, die anderen nachher.
-- Chinesisches Sprichwort
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
From 1ab4e889c631a11587766ab1375a16558141c8b3 Mon Sep 17 00:00:00 2001
From: Christian Brabandt <[email protected]>
Date: Fri, 15 Sep 2017 12:05:14 +0200
Subject: [PATCH] fix some potential E363 maxmemtot errors for matchit and
matchparen
---
runtime/doc/options.txt | 2 ++
runtime/pack/dist/opt/matchit/plugin/matchit.vim | 8 +++++++-
runtime/plugin/matchparen.vim | 12 +++++++++++-
3 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index 65a9d17ea..027e7e23c 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -5233,6 +5233,8 @@ A jump table for the options with a short description can be found at |Q_op|.
Running into the limit often means that the pattern is very
inefficient or too complex. This may already happen with the pattern
"\(.\)*" on a very long line. ".*" works much better.
+ Might also happen, on redraw, when syntax rules try to match a complex
+ file structure.
Vim may run out of memory before hitting the 'maxmempattern' limit.
*'maxmemtot'* *'mmt'*
diff --git a/runtime/pack/dist/opt/matchit/plugin/matchit.vim b/runtime/pack/dist/opt/matchit/plugin/matchit.vim
index 5e9df89c4..60d94e69f 100644
--- a/runtime/pack/dist/opt/matchit/plugin/matchit.vim
+++ b/runtime/pack/dist/opt/matchit/plugin/matchit.vim
@@ -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
diff --git a/runtime/plugin/matchparen.vim b/runtime/plugin/matchparen.vim
index 0fa5c4d22..fb1ce0053 100644
--- a/runtime/plugin/matchparen.vim
+++ b/runtime/plugin/matchparen.vim
@@ -107,6 +107,7 @@ function! s:Highlight_Matching_Pair()
" certain syntax types (string, comment, etc.), for use as searchpairpos()'s
" skip argument.
" We match "escape" for special items, such as lispEscapeSpecial.
+ " Note: this may throw E363: pattern uses more memory than 'maxmempattern'
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
@@ -114,7 +115,16 @@ function! s:Highlight_Matching_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 !has("syntax") || !exists("g:syntax_on")
+ let s_skip = "0"
+ else
+ 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$')
--
2.17.0