diff --git a/plugin/delimitMate.vim b/plugin/delimitMate.vim index 4c0776e..6c6e3e9 100644 --- a/plugin/delimitMate.vim +++ b/plugin/delimitMate.vim @@ -279,6 +279,10 @@ function! s:FlushBuffer() " {{{ return '' endfunction " }}} +function! s:empty_buffer() + return empty(b:_l_delimitMate_buffer) +endfunction + "}}} " Mappers: {{{ @@ -331,7 +335,7 @@ endfunction "}}} function! s:ExtraMappings() "{{{ " If pair is empty, delete both delimiters: - inoremap delimitMateBS =delimitMate#BS() + inoremap delimitMateBS delimitMate#WithinEmptyPair() ? "\=delimitMate#BS()\" : "\" if !hasmapto('delimitMateBS','i') && maparg(''. 'i') == '' silent! imap delimitMateBS endif @@ -367,7 +371,7 @@ function! s:ExtraMappings() "{{{ \ 'ScrollWheelRight', 'S-ScrollWheelRight', 'C-ScrollWheelRight'] " Flush the char buffer on movement keystrokes: for map in keys - exec 'inoremap delimitMate'.map.' !empty(b:_l_delimitMate_buffer) ? "=delimitMate#Finish(1)<'.map.'>" : "<'.map.'>"' + exec 'inoremap delimitMate'.map.' !empty_buffer() ? "=delimitMate#Finish(1)<'.map.'>" : "<'.map.'>"' if !hasmapto('delimitMate'.map, 'i') && maparg('<'.map.'>', 'i') == '' exec 'silent! imap <'.map.'> delimitMate'.map endif @@ -383,7 +387,7 @@ function! s:ExtraMappings() "{{{ endif " Except when pop-up menu is active: for map in ['Up', 'Down', 'PageUp', 'PageDown', 'S-Down', 'S-Up'] - exec 'inoremap delimitMate'.map.' pumvisible() \|\| empty(b:_l_delimitMate_buffer) ? "\<'.map.'>" : "\=\Finish()\\<'.map.'>"' + exec 'inoremap delimitMate'.map.' pumvisible() \|\| empty_buffer() ? "\<'.map.'>" : "\=\Finish()\\<'.map.'>"' if !hasmapto('delimitMate'.map, 'i') && maparg('<'.map.'>', 'i') == '' exec 'silent! imap <'.map.'> delimitMate'.map endif