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
+12 -7
View File
@@ -382,18 +382,23 @@ function! delimitMate#JumpAny() " {{{
endfunction " delimitMate#JumpAny() }}} endfunction " delimitMate#JumpAny() }}}
function! delimitMate#SkipDelim(char) "{{{ function! delimitMate#SkipDelim(char) "{{{
let cur = strpart( getline('.'), col('.')-2, 3 ) let col = col('.') - 1
if cur[0] == "\\" 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 " Escaped character
return a:char return a:char
elseif cur[1] == a:char elseif cur == a:char
" Exit pair " Exit pair
"return delimitMate#WriteBefore(a:char) "return delimitMate#WriteBefore(a:char)
return a:char . delimitMate#Del() return a:char . delimitMate#Del()
"elseif cur[1] == ' ' && cur[2] == a:char elseif delimitMate#IsEmptyPair( pre . 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 )
" Add closing delimiter and jump back to the middle. " Add closing delimiter and jump back to the middle.
call insert(b:delimitMate_buffer, a:char) call insert(b:delimitMate_buffer, a:char)
return delimitMate#WriteAfter(a:char) return delimitMate#WriteAfter(a:char)
+6 -2
View File
@@ -176,8 +176,8 @@ function! delimitMateTests#Main(known) " {{{
call Type("Visual line wrapping quote empty line", "\<Esc>V,\"", ['""'], ['visual_leader:","']) call Type("Visual line wrapping quote empty line", "\<Esc>V,\"", ['""'], ['visual_leader:","'])
" Smart quotes " Smart quotes
call Type("Smart quote alphanumeric", "alpha\"numeric", ['alpha"numeric|'], []) call Type("Smart quote alphanumeric", "a\"4", ['a"4|'], [])
call RepeatLast("Smart quote alphanumeric", ['alpha"numeric|alpha"numeric|']) call RepeatLast("Smart quote alphanumeric", ['a"4|a"4|'])
" Smart quotes " Smart quotes
call Type("Smart quote escaped", "esc\\\"", ['esc\"|'], []) call Type("Smart quote escaped", "esc\\\"", ['esc\"|'], [])
@@ -222,6 +222,9 @@ function! delimitMateTests#Main(known) " {{{
" Autoclose and beginning of line " Autoclose and beginning of line
call Type("Autoclose and beginning of line", "'\<Left>\<Left>\<Esc>i'", ["'|\"'"], ["autoclose:0"]) 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: {{{ " Show results: {{{
@@ -251,3 +254,4 @@ function! delimitMateTests#Main(known) " {{{
" }}} " }}}
endfunction " }}} endfunction " }}}
" vim:foldmethod=marker:foldcolumn=4 " vim:foldmethod=marker:foldcolumn=4