mirror of
https://github.com/Raimondi/delimitMate.git
synced 2025-12-08 13:44:47 +08:00
Allow multibyte chars with <BS>. Closes #78.
- Add delimitMate#GetCharUnderCursor() - Add delimitMate#GetCharBeforeCursor() - Simplify delimitMate#Del()
This commit is contained in:
@@ -60,6 +60,20 @@ function! delimitMate#IsEmptyPair(str) "{{{
|
|||||||
return 0
|
return 0
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
|
function! delimitMate#GetCharBeforeCursor() "{{{
|
||||||
|
let line = getline('.')
|
||||||
|
let col = col('.') - 1
|
||||||
|
" get char before the cursor.
|
||||||
|
return matchstr(line[: col - 1], '.$')
|
||||||
|
endfunction "delimitMate#GetCharUnderCursor }}}
|
||||||
|
|
||||||
|
function! delimitMate#GetCharUnderCursor() "{{{
|
||||||
|
let line = getline('.')
|
||||||
|
let col = col('.') - 1
|
||||||
|
" get char under the cursor.
|
||||||
|
return matchstr(line[col :], '^.')
|
||||||
|
endfunction "delimitMate#GetCharUnderCursor }}}
|
||||||
|
|
||||||
function! delimitMate#IsCRExpansion() " {{{
|
function! delimitMate#IsCRExpansion() " {{{
|
||||||
let nchar = getline(line('.')-1)[-1:]
|
let nchar = getline(line('.')-1)[-1:]
|
||||||
let schar = getline(line('.')+1)[:0]
|
let schar = getline(line('.')+1)[:0]
|
||||||
@@ -99,8 +113,13 @@ function! delimitMate#IsSpaceExpansion() " {{{
|
|||||||
endfunction " }}} IsSpaceExpansion()
|
endfunction " }}} IsSpaceExpansion()
|
||||||
|
|
||||||
function! delimitMate#WithinEmptyPair() "{{{
|
function! delimitMate#WithinEmptyPair() "{{{
|
||||||
let cur = strpart( getline('.'), col('.')-2, 2 )
|
let line = getline('.')
|
||||||
return delimitMate#IsEmptyPair( cur )
|
let col = col('.') - 1
|
||||||
|
" get char before the cursor.
|
||||||
|
let char1 = delimitMate#GetCharBeforeCursor()
|
||||||
|
" get char under the cursor.
|
||||||
|
let char2 = delimitMate#GetCharUnderCursor()
|
||||||
|
return delimitMate#IsEmptyPair( char1.char2 )
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! delimitMate#WriteBefore(str) "{{{
|
function! delimitMate#WriteBefore(str) "{{{
|
||||||
@@ -426,11 +445,8 @@ endfunction " }}} delimitMate#BS()
|
|||||||
|
|
||||||
function! delimitMate#Del() " {{{
|
function! delimitMate#Del() " {{{
|
||||||
if len(b:_l_delimitMate_buffer) > 0
|
if len(b:_l_delimitMate_buffer) > 0
|
||||||
let line = getline('.')
|
|
||||||
let col = col('.') - 2
|
|
||||||
call delimitMate#RmBuffer(1)
|
call delimitMate#RmBuffer(1)
|
||||||
call setline('.', line[:col] . line[col+2:])
|
return "\<Del>"
|
||||||
return ''
|
|
||||||
else
|
else
|
||||||
return "\<Del>"
|
return "\<Del>"
|
||||||
endif
|
endif
|
||||||
|
|||||||
Reference in New Issue
Block a user