ParenDelim: improve smart_matchpairs handling

* move the check up
* only handle it when smart_matchpairs is configured (default)
This commit is contained in:
Daniel Hahler
2014-02-06 02:20:29 +01:00
parent a1f21e8ef5
commit 1c45f7bbde

View File

@@ -352,16 +352,17 @@ function! delimitMate#ParenDelim(right) " {{{
endif
let line = getline('.')
let col = col('.')-2
let tail = len(line) == (col + 1) ? s:g('eol_marker') : ''
let smart_matchpairs = substitute(s:g('smart_matchpairs'), '\\!', left, 'g')
let smart_matchpairs = substitute(smart_matchpairs, '\\#', a:right, 'g')
if s:g('smart_matchpairs') != '' &&
\ line[col+1:] =~ smart_matchpairs
return left
"elseif (col) < 0
" call setline('.',a:right.line)
if s:g('smart_matchpairs') != ''
let smart_matchpairs = substitute(s:g('smart_matchpairs'), '\\!', left, 'g')
let smart_matchpairs = substitute(smart_matchpairs, '\\#', a:right, 'g')
if line[col+1:] =~ smart_matchpairs
return left
endif
endif
let tail = len(line) == (col + 1) ? s:g('eol_marker') : ''
"if (col) < 0
" call setline('.',a:right.line)
"endif
return left . a:right . tail . repeat("\<Left>", len(split(tail, '\zs')) + 1)
endfunction " }}}