Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Shougo committed Sep 24, 2023
1 parent 59d74b7 commit 240130e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
40 changes: 20 additions & 20 deletions autoload/dpp/min.vim
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
function dpp#min#load_state(path) abort
if !('#dpp'->exists())
call dpp#min#_init()
endif
if g:dpp#_is_sudo | return 1 | endif
let g:dpp#_base_path = a:path->expand()

const state = printf('%s/state_%s.vim', g:dpp#_base_path, g:dpp#_progname)
if !(state->filereadable()) | return 1 | endif
try
execute 'source' state->fnameescape()
catch
if v:exception !=# 'Cache loading error'
call dpp#util#_error('Loading state error: ' .. v:exception)
endif
call dpp#util#_clear_state()
return 1
endtry
endfunction
function dpp#min#_init() abort
let g:dpp#_cache_version = 1
let g:dpp#_plugins = {}
Expand All @@ -14,7 +33,7 @@ function dpp#min#_init() abort
autocmd!
augroup END
endfunction
function! dpp#min#_load_cache_raw(vimrcs=[]) abort
function dpp#min#_load_cache_raw(vimrcs=[]) abort
let g:dpp#_vimrcs = a:vimrcs
const cache = printf('%s/cache_%s.vim', g:dpp#_base_path, g:dpp#_progname)
const time = cache->getftime()
Expand All @@ -26,22 +45,3 @@ function! dpp#min#_load_cache_raw(vimrcs=[]) abort
return has('nvim') ? cache->readfile()->json_decode()
\ : cache->readfile()[0]->js_decode()
endfunction
function! dpp#min#load_state(path) abort
if !('#dpp'->exists())
call dpp#min#_init()
endif
if g:dpp#_is_sudo | return 1 | endif
let g:dpp#_base_path = a:path->expand()

const state = printf('%s/state_%s.vim', g:dpp#_base_path, g:dpp#_progname)
if !(state->filereadable()) | return 1 | endif
try
execute 'source' state->fnameescape()
catch
if v:exception !=# 'Cache loading error'
call dpp#util#_error('Loading state error: ' .. v:exception)
endif
call dpp#util#_clear_state()
return 1
endtry
endfunction
2 changes: 1 addition & 1 deletion autoload/dpp/util.vim
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ function s:tsort_impl(target, mark, sorted) abort
call add(a:sorted, a:target)
endfunction

function! dpp#util#_clear_state() abort
function dpp#util#_clear_state() abort
const base = g:dpp#_base_path
for cache in (base .. '/state_*.vim')->glob(v:true, v:true)
\ + (base .. '/cache_*')->glob(v:true, v:true)
Expand Down

0 comments on commit 240130e

Please sign in to comment.