diff --git a/autoload/neosnippet/commands.vim b/autoload/neosnippet/commands.vim index 297d9df..846b836 100644 --- a/autoload/neosnippet/commands.vim +++ b/autoload/neosnippet/commands.vim @@ -137,8 +137,7 @@ function! neosnippet#commands#_clear_markers() "{{{ let expand_stack = neosnippet#variables#expand_stack() " Get patterns and count. - if !&l:modifiable - \ || !&l:modified + if !&l:modifiable || !&l:modified \ || empty(expand_stack) \ || neosnippet#variables#current_neosnippet().trigger return diff --git a/autoload/neosnippet/handlers.vim b/autoload/neosnippet/handlers.vim index 3977601..5e37bd0 100644 --- a/autoload/neosnippet/handlers.vim +++ b/autoload/neosnippet/handlers.vim @@ -84,6 +84,22 @@ function! neosnippet#handlers#_complete_done() "{{{ \ '', 0, '', trigger) endfunction"}}} +function! neosnippet#handlers#_cursor_moved() "{{{ + let expand_stack = neosnippet#variables#expand_stack() + + " Get patterns and count. + if !&l:modifiable || !&l:modified + \ || empty(expand_stack) + return + endif + + let expand_info = expand_stack[-1] + if expand_info.begin_line == expand_info.end_line + \ && line('.') != expand_info.begin_line + call neosnippet#commands#_clear_markers() + endif +endfunction"}}} + let &cpo = s:save_cpo unlet s:save_cpo diff --git a/autoload/neosnippet/init.vim b/autoload/neosnippet/init.vim index ec4fff6..04ae884 100644 --- a/autoload/neosnippet/init.vim +++ b/autoload/neosnippet/init.vim @@ -88,6 +88,8 @@ function! s:initialize_others() "{{{ \ call neosnippet#variables#set_snippets({}) autocmd BufEnter * \ call neosnippet#mappings#_clear_select_mode_mappings() + autocmd CursorMoved,CursorMovedI * + \ call neosnippet#handlers#_cursor_moved() autocmd BufWritePre * NeoSnippetClearMarkers augroup END"}}}