From cfc99eedb5caf3d6baf867db5220a891b4686699 Mon Sep 17 00:00:00 2001 From: Shougo Matsushita Date: Wed, 16 Dec 2015 03:40:40 +0900 Subject: [PATCH] Fix #306 clear all markers when BufWritePost --- autoload/neosnippet/handlers.vim | 16 ++++++++++++++++ autoload/neosnippet/init.vim | 6 ++++-- autoload/neosnippet/view.vim | 6 +++--- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/autoload/neosnippet/handlers.vim b/autoload/neosnippet/handlers.vim index 70bda5f..c4e1aa4 100644 --- a/autoload/neosnippet/handlers.vim +++ b/autoload/neosnippet/handlers.vim @@ -101,6 +101,22 @@ function! neosnippet#handlers#_cursor_moved() "{{{ endif endfunction"}}} +function! neosnippet#handlers#_all_clear_markers() "{{{ + let pos = getpos('.') + + try + " Search out of range. + while neosnippet#view#_search_outof_range(col('.')) + endwhile + finally + stopinsert + + call setpos('.', pos) + + call neosnippet#variables#clear_expand_stack() + endtry +endfunction"}}} + function! neosnippet#handlers#_get_in_paren(str) abort "{{{ let s = '' let level = 0 diff --git a/autoload/neosnippet/init.vim b/autoload/neosnippet/init.vim index 3aaf2f3..99f0f8e 100644 --- a/autoload/neosnippet/init.vim +++ b/autoload/neosnippet/init.vim @@ -50,7 +50,8 @@ function! s:initialize_others() "{{{ augroup neosnippet "{{{ autocmd! " Set make cache event. - autocmd FileType * call neosnippet#commands#_make_cache(&filetype) + autocmd FileType * + \ call neosnippet#commands#_make_cache(&filetype) " Re make cache events autocmd BufWritePost *.snip,*.snippets \ call neosnippet#variables#set_snippets({}) @@ -58,7 +59,8 @@ function! s:initialize_others() "{{{ \ call neosnippet#mappings#_clear_select_mode_mappings() autocmd CursorMoved,CursorMovedI * \ call neosnippet#handlers#_cursor_moved() - autocmd BufWritePre * NeoSnippetClearMarkers + autocmd BufWritePre * + \ call neosnippet#handlers#_all_clear_markers() augroup END"}}} if exists('v:completed_item') diff --git a/autoload/neosnippet/view.vim b/autoload/neosnippet/view.vim index 1f01159..f4f51af 100644 --- a/autoload/neosnippet/view.vim +++ b/autoload/neosnippet/view.vim @@ -140,7 +140,7 @@ function! neosnippet#view#_jump(_, col) "{{{ " Get patterns and count. if empty(expand_stack) - return s:search_outof_range(a:col) + return neosnippet#view#_search_outof_range(a:col) endif let expand_info = expand_stack[-1] @@ -170,7 +170,7 @@ function! neosnippet#view#_jump(_, col) "{{{ let expand_stack = neosnippet#variables#expand_stack() let expand_stack = expand_stack[: -2] - return s:search_outof_range(a:col) + return neosnippet#view#_search_outof_range(a:col) endfunction"}}} function! s:indent_snippet(begin, end) "{{{ @@ -269,7 +269,7 @@ function! neosnippet#view#_search_snippet_range(start, end, cnt, ...) "{{{ return 0 endfunction"}}} -function! s:search_outof_range(col) "{{{ +function! neosnippet#view#_search_outof_range(col) "{{{ call s:substitute_placeholder_marker(1, 0, 0) let pattern = neosnippet#get_placeholder_marker_pattern()