From 453d4889876cb89fd1381f68645673250405228d Mon Sep 17 00:00:00 2001 From: Miao Jiang Date: Sun, 20 Jan 2019 12:02:09 +0800 Subject: [PATCH] Compatible with vim 7.3, fixes #233 --- plugin/auto-pairs.vim | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/plugin/auto-pairs.vim b/plugin/auto-pairs.vim index d06796c..72a1424 100644 --- a/plugin/auto-pairs.vim +++ b/plugin/auto-pairs.vim @@ -143,6 +143,7 @@ func! s:matchend(text, open) end return [a:text, strpart(a:text, 0, len(a:text)-len(m)), m] endf + func! s:matchbegin(text, close) let m = matchstr(a:text, '^\V'.a:close) if m == "" @@ -186,6 +187,9 @@ func! AutoPairsInsert(key) " check close pairs for [open, close, opt] in b:AutoPairsList + if close == '' + continue + end if a:key == g:AutoPairsWildClosedPair || opt['mapclose'] && close[0] == a:key " the close pair is in the same line let m = matchstr(afterline, '^\v\s*\V'.close) @@ -213,38 +217,38 @@ func! AutoPairsInsert(key) " check open pairs let text=before.a:key for [open, close, opt] in b:AutoPairsList - let m = s:matchend(text, open) - if len(m) > 0 + let ms = s:matchend(text, open) + if len(ms) > 0 " process the open pair " remove inserted pair " eg: if the pairs include < > and " when