Fix no autoclose at start of line replaces right char.

This commit is contained in:
Israel Chauca Fuentes
2010-05-13 15:27:36 -05:00
parent a317b6ead7
commit 45c66a4d07
2 changed files with 18 additions and 9 deletions

View File

@@ -382,18 +382,23 @@ function! delimitMate#JumpAny() " {{{
endfunction " delimitMate#JumpAny() }}}
function! delimitMate#SkipDelim(char) "{{{
let cur = strpart( getline('.'), col('.')-2, 3 )
if cur[0] == "\\"
let col = col('.') - 1
let line = getline('.')
if col > 0
let cur = line[col]
let pre = line[col-1]
else
let cur = line[col]
let pre = ""
endif
if pre == "\\"
" Escaped character
return a:char
elseif cur[1] == a:char
elseif cur == a:char
" Exit pair
"return delimitMate#WriteBefore(a:char)
return a:char . delimitMate#Del()
"elseif cur[1] == ' ' && cur[2] == a:char
"" I'm leaving this in case someone likes it. Jump an space and delimiter.
"return "\<Right>\<Right>"
elseif delimitMate#IsEmptyPair( cur[0] . a:char )
elseif delimitMate#IsEmptyPair( pre . a:char )
" Add closing delimiter and jump back to the middle.
call insert(b:delimitMate_buffer, a:char)
return delimitMate#WriteAfter(a:char)

View File

@@ -176,8 +176,8 @@ function! delimitMateTests#Main(known) " {{{
call Type("Visual line wrapping quote empty line", "\<Esc>V,\"", ['""'], ['visual_leader:","'])
" Smart quotes
call Type("Smart quote alphanumeric", "alpha\"numeric", ['alpha"numeric|'], [])
call RepeatLast("Smart quote alphanumeric", ['alpha"numeric|alpha"numeric|'])
call Type("Smart quote alphanumeric", "a\"4", ['a"4|'], [])
call RepeatLast("Smart quote alphanumeric", ['a"4|a"4|'])
" Smart quotes
call Type("Smart quote escaped", "esc\\\"", ['esc\"|'], [])
@@ -222,6 +222,9 @@ function! delimitMateTests#Main(known) " {{{
" Autoclose and beginning of line
call Type("Autoclose and beginning of line", "'\<Left>\<Left>\<Esc>i'", ["'|\"'"], ["autoclose:0"])
" Manual close at start of line
call Type("Manual close at start of line", "m)\<Left>\<Left>)", [')|m)'], ["autoclose:0"])
"}}}
" Show results: {{{
@@ -251,3 +254,4 @@ function! delimitMateTests#Main(known) " {{{
" }}}
endfunction " }}}
" vim:foldmethod=marker:foldcolumn=4