From 739d2f9bd4c523b6d8ac6e58a844b073fb119800 Mon Sep 17 00:00:00 2001 From: Israel Chauca Fuentes Date: Wed, 27 Mar 2013 18:33:58 -0400 Subject: [PATCH] Call #Finish() only when necessary for . As mentioned in #124. --- plugin/delimitMate.vim | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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