diff --git a/autoload/startify.vim b/autoload/startify.vim index ed01f92..7e62f0e 100644 --- a/autoload/startify.vim +++ b/autoload/startify.vim @@ -235,27 +235,31 @@ endfunction " Function: #session_write {{{1 function! startify#session_write(spath) - let ssop = &sessionoptions - try - " if this function is called while being in the Startify buffer - " (by loading another session or running :SSave/:SLoad directly) - " switch back to the previous buffer before saving the session - if &filetype == 'startify' - let callingbuffer = bufnr('#') - if callingbuffer > 0 - execute 'buffer' callingbuffer - endif + " if this function is called while being in the Startify buffer + " (by loading another session or running :SSave/:SLoad directly) + " switch back to the previous buffer before saving the session + if &filetype == 'startify' + let callingbuffer = bufnr('#') + if callingbuffer > 0 + execute 'buffer' callingbuffer endif - " prevent saving already deleted buffers that were in the arglist - for arg in argv() - if !buflisted(arg) - execute 'argdelete' fnameescape(arg) - endif - endfor - set sessionoptions-=options + endif + " prevent saving already deleted buffers that were in the arglist + for arg in argv() + if !buflisted(arg) + execute 'silent! argdelete' fnameescape(arg) + endif + endfor + + let ssop = &sessionoptions + set sessionoptions-=options + try execute 'mksession!' a:spath catch - execute 'echoerr' string(v:exception) + echohl ErrorMsg + echomsg v:exception + echohl NONE + return finally let &sessionoptions = ssop endtry