mirror of
https://github.com/Raimondi/delimitMate.git
synced 2025-12-07 21:24:51 +08:00
Consider indentation with BS on empty expanded CR.
This commit is contained in:
@@ -75,18 +75,17 @@ function! delimitMate#GetCharFromCursor(...) "{{{
|
|||||||
return matchstr(line, '.\ze'.repeat('.', pos).'$')
|
return matchstr(line, '.\ze'.repeat('.', pos).'$')
|
||||||
endfunction "delimitMate#GetCharFromCursor }}}
|
endfunction "delimitMate#GetCharFromCursor }}}
|
||||||
|
|
||||||
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 = matchstr(getline(line('.')+1), '^\s*\zs\S')
|
||||||
" TODO: Consider whitespace?
|
let isEmpty = a:0 ? getline('.') =~ '^\s*$' : empty(getline('.'))
|
||||||
let isEmpty = getline('.') == ""
|
if index(b:_l_delimitMate_left_delims, nchar) > -1
|
||||||
if index(b:_l_delimitMate_left_delims, nchar) > -1 &&
|
\ && index(b:_l_delimitMate_left_delims, nchar) == index(b:_l_delimitMate_right_delims, schar)
|
||||||
\ index(b:_l_delimitMate_left_delims, nchar) == index(b:_l_delimitMate_right_delims, schar) &&
|
\ && isEmpty
|
||||||
\ isEmpty
|
|
||||||
return 1
|
return 1
|
||||||
elseif index(b:_l_delimitMate_quotes_list, nchar) > -1 &&
|
elseif index(b:_l_delimitMate_quotes_list, nchar) > -1
|
||||||
\ index(b:_l_delimitMate_quotes_list, nchar) == index(b:_l_delimitMate_quotes_list, schar) &&
|
\ && index(b:_l_delimitMate_quotes_list, nchar) == index(b:_l_delimitMate_quotes_list, schar)
|
||||||
\ isEmpty
|
\ && isEmpty
|
||||||
return 1
|
return 1
|
||||||
else
|
else
|
||||||
return 0
|
return 0
|
||||||
@@ -453,7 +452,7 @@ function! delimitMate#BS() " {{{
|
|||||||
return "\<BS>" . delimitMate#Del()
|
return "\<BS>" . delimitMate#Del()
|
||||||
endif
|
endif
|
||||||
if delimitMate#IsCRExpansion()
|
if delimitMate#IsCRExpansion()
|
||||||
return "\<BS>\<Del>"
|
return "\<BS>" . repeat("\<Del>", len(matchstr(getline(line('.') + 1), '^\s*\S')))
|
||||||
endif
|
endif
|
||||||
return "\<BS>"
|
return "\<BS>"
|
||||||
endfunction " }}} delimitMate#BS()
|
endfunction " }}} delimitMate#BS()
|
||||||
|
|||||||
@@ -18,3 +18,9 @@ exec "normal i(\<CR>test)x"
|
|||||||
test
|
test
|
||||||
)x
|
)x
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
# Consider indentation with BS inside an empty CR expansion.
|
||||||
|
%d
|
||||||
|
exec "normal i(\<CR>\<BS>x"
|
||||||
|
================================================================================
|
||||||
|
(x)
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user