Fix #306 clear all markers when BufWritePost

This commit is contained in:
Shougo Matsushita 2015-12-16 03:40:40 +09:00
parent 4c1650096f
commit cfc99eedb5
3 changed files with 23 additions and 5 deletions

View File

@ -101,6 +101,22 @@ function! neosnippet#handlers#_cursor_moved() "{{{
endif endif
endfunction"}}} 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 "{{{ function! neosnippet#handlers#_get_in_paren(str) abort "{{{
let s = '' let s = ''
let level = 0 let level = 0

View File

@ -50,7 +50,8 @@ function! s:initialize_others() "{{{
augroup neosnippet "{{{ augroup neosnippet "{{{
autocmd! autocmd!
" Set make cache event. " Set make cache event.
autocmd FileType * call neosnippet#commands#_make_cache(&filetype) autocmd FileType *
\ call neosnippet#commands#_make_cache(&filetype)
" Re make cache events " Re make cache events
autocmd BufWritePost *.snip,*.snippets autocmd BufWritePost *.snip,*.snippets
\ call neosnippet#variables#set_snippets({}) \ call neosnippet#variables#set_snippets({})
@ -58,7 +59,8 @@ function! s:initialize_others() "{{{
\ call neosnippet#mappings#_clear_select_mode_mappings() \ call neosnippet#mappings#_clear_select_mode_mappings()
autocmd CursorMoved,CursorMovedI * autocmd CursorMoved,CursorMovedI *
\ call neosnippet#handlers#_cursor_moved() \ call neosnippet#handlers#_cursor_moved()
autocmd BufWritePre * NeoSnippetClearMarkers autocmd BufWritePre *
\ call neosnippet#handlers#_all_clear_markers()
augroup END"}}} augroup END"}}}
if exists('v:completed_item') if exists('v:completed_item')

View File

@ -140,7 +140,7 @@ function! neosnippet#view#_jump(_, col) "{{{
" Get patterns and count. " Get patterns and count.
if empty(expand_stack) if empty(expand_stack)
return s:search_outof_range(a:col) return neosnippet#view#_search_outof_range(a:col)
endif endif
let expand_info = expand_stack[-1] 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 = neosnippet#variables#expand_stack()
let expand_stack = expand_stack[: -2] let expand_stack = expand_stack[: -2]
return s:search_outof_range(a:col) return neosnippet#view#_search_outof_range(a:col)
endfunction"}}} endfunction"}}}
function! s:indent_snippet(begin, end) "{{{ function! s:indent_snippet(begin, end) "{{{
@ -269,7 +269,7 @@ function! neosnippet#view#_search_snippet_range(start, end, cnt, ...) "{{{
return 0 return 0
endfunction"}}} endfunction"}}}
function! s:search_outof_range(col) "{{{ function! neosnippet#view#_search_outof_range(col) "{{{
call s:substitute_placeholder_marker(1, 0, 0) call s:substitute_placeholder_marker(1, 0, 0)
let pattern = neosnippet#get_placeholder_marker_pattern() let pattern = neosnippet#get_placeholder_marker_pattern()