Fix cache problem

This commit is contained in:
Shougo Matsushita 2015-12-23 21:17:05 +09:00
parent 49b1743d03
commit 457d5c8939

View File

@ -37,8 +37,8 @@ function! neosnippet#parser#_parse_snippets(filename) "{{{
let cache_dir = neosnippet#variables#data_dir() let cache_dir = neosnippet#variables#data_dir()
if s:Cache.check_old_cache(cache_dir, a:filename) if s:Cache.check_old_cache(cache_dir, a:filename)
let snippets = s:parse(a:filename) let [snippets, sourced] = s:parse(a:filename)
if len(snippets) > 5 && !neosnippet#util#is_sudo() if len(snippets) > 5 && !neosnippet#util#is_sudo() && !sourced
call s:Cache.writefile( call s:Cache.writefile(
\ cache_dir, a:filename, [string(snippets)]) \ cache_dir, a:filename, [string(snippets)])
endif endif
@ -71,6 +71,7 @@ function! s:parse(snippets_file) "{{{
let snippet_dict = {} let snippet_dict = {}
let linenr = 1 let linenr = 1
let snippets = {} let snippets = {}
let sourced = 0
for line in readfile(a:snippets_file) for line in readfile(a:snippets_file)
if line =~ '^\h\w*.*\s$' if line =~ '^\h\w*.*\s$'
@ -96,6 +97,7 @@ function! s:parse(snippets_file) "{{{
\ neosnippet#helpers#get_snippets_directory(), ','), \ neosnippet#helpers#get_snippets_directory(), ','),
\ matchstr(line, '^source\s\+\zs.*$')), '\n') \ matchstr(line, '^source\s\+\zs.*$')), '\n')
execute 'source' fnameescape(file) execute 'source' fnameescape(file)
let sourced = 1
endfor endfor
elseif line =~ '^delete\s' elseif line =~ '^delete\s'
let name = matchstr(line, '^delete\s\+\zs.*$') let name = matchstr(line, '^delete\s\+\zs.*$')
@ -135,7 +137,7 @@ function! s:parse(snippets_file) "{{{
\ snippets, dup_check, a:snippets_file) \ snippets, dup_check, a:snippets_file)
endif endif
return snippets return [snippets, sourced]
endfunction"}}} endfunction"}}}
function! s:parse_snippet_name(snippets_file, line, linenr, dup_check) "{{{ function! s:parse_snippet_name(snippets_file, line, linenr, dup_check) "{{{