mirror of
https://github.com/Raimondi/delimitMate.git
synced 2025-12-07 13:14:35 +08:00
Don't use setline() for left-side matchpair.
This commit is contained in:
@@ -353,34 +353,31 @@ function! delimitMate#SkipDelim(char) "{{{
|
|||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! delimitMate#ParenDelim(char) " {{{
|
function! delimitMate#ParenDelim(right) " {{{
|
||||||
if delimitMate#IsForbidden(a:char)
|
let left = s:g('left_delims')[index(s:g('right_delims'),a:right)]
|
||||||
return ''
|
if delimitMate#IsForbidden(a:right)
|
||||||
|
return left
|
||||||
endif
|
endif
|
||||||
" Try to balance matchpairs
|
" Try to balance matchpairs
|
||||||
if s:g('balance_matchpairs') &&
|
if s:g('balance_matchpairs') &&
|
||||||
\ delimitMate#BalancedParens(a:char) <= 0
|
\ delimitMate#BalancedParens(a:right) < 0
|
||||||
return ''
|
return left
|
||||||
endif
|
endif
|
||||||
let line = getline('.')
|
let line = getline('.')
|
||||||
let col = col('.')-2
|
let col = col('.')-2
|
||||||
let tail = len(line) == (col + 1) ? s:g('eol_marker') : ''
|
let tail = len(line) == (col + 1) ? s:g('eol_marker') : ''
|
||||||
let left = s:g('left_delims')[index(s:g('right_delims'),a:char)]
|
|
||||||
let smart_matchpairs = substitute(s:g('smart_matchpairs'), '\\!', left, 'g')
|
let smart_matchpairs = substitute(s:g('smart_matchpairs'), '\\!', left, 'g')
|
||||||
let smart_matchpairs = substitute(smart_matchpairs, '\\#', a:char, 'g')
|
let smart_matchpairs = substitute(smart_matchpairs, '\\#', a:right, 'g')
|
||||||
|
|
||||||
if s:g('smart_matchpairs') != '' &&
|
if s:g('smart_matchpairs') != '' &&
|
||||||
\ line[col+1:] =~ smart_matchpairs
|
\ line[col+1:] =~ smart_matchpairs
|
||||||
return ''
|
return left
|
||||||
elseif (col) < 0
|
"elseif (col) < 0
|
||||||
call setline('.',a:char.line)
|
" call setline('.',a:right.line)
|
||||||
call delimitMate#AddToBuffer(a:char)
|
" call delimitMate#AddToBuffer(a:right)
|
||||||
else
|
|
||||||
"echom string(col).':'.line[:(col)].'|'.line[(col+1):]
|
|
||||||
call setline('.',line[:(col)].a:char.tail.line[(col+1):])
|
|
||||||
call delimitMate#AddToBuffer(a:char . tail)
|
|
||||||
endif
|
endif
|
||||||
return ''
|
call delimitMate#AddToBuffer(a:right . tail)
|
||||||
|
return left . a:right . tail . repeat("\<Left>", len(split(tail, '\zs')) + 1)
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
|
||||||
function! delimitMate#QuoteDelim(char) "{{{
|
function! delimitMate#QuoteDelim(char) "{{{
|
||||||
|
|||||||
@@ -296,7 +296,7 @@ function! s:AutoClose() "{{{
|
|||||||
while i < len(s:g('matchpairs_list'))
|
while i < len(s:g('matchpairs_list'))
|
||||||
let ld = s:g('left_delims')[i] == '|' ? '<bar>' : s:g('left_delims')[i]
|
let ld = s:g('left_delims')[i] == '|' ? '<bar>' : s:g('left_delims')[i]
|
||||||
let rd = s:g('right_delims')[i] == '|' ? '<bar>' : s:g('right_delims')[i]
|
let rd = s:g('right_delims')[i] == '|' ? '<bar>' : s:g('right_delims')[i]
|
||||||
exec 'inoremap <silent> <Plug>delimitMate' . ld . ' ' . ld . '<C-R>=delimitMate#ParenDelim("' . escape(rd, '|') . '")<CR>'
|
exec 'inoremap <silent> <Plug>delimitMate' . ld . ' <C-R>=delimitMate#ParenDelim("' . escape(rd, '|') . '")<CR>'
|
||||||
exec 'silent! imap <unique> <buffer> '.ld.' <Plug>delimitMate'.ld
|
exec 'silent! imap <unique> <buffer> '.ld.' <Plug>delimitMate'.ld
|
||||||
let i += 1
|
let i += 1
|
||||||
endwhile
|
endwhile
|
||||||
|
|||||||
Reference in New Issue
Block a user