Make :SLoad! source last used session on Unix

Closes https://github.com/mhinz/vim-startify/issues/352
This commit is contained in:
Marco Hinz 2019-01-29 23:29:59 +01:00
parent 06f2f59d4f
commit 0459cd0952
No known key found for this signature in database
GPG key ID: 1C980A1B657B4A4F
3 changed files with 15 additions and 15 deletions

View file

@ -164,7 +164,7 @@ function! startify#insane_in_the_membrane(on_vimenter) abort
endfunction
" Function: #session_load {{{1
function! startify#session_load(...) abort
function! startify#session_load(source_last_session, ...) abort
if !isdirectory(s:session_dir)
echomsg 'The session directory does not exist: '. s:session_dir
return
@ -177,17 +177,15 @@ function! startify#session_load(...) abort
if a:0
let spath .= a:1
elseif a:source_last_session && !has('win32')
let spath .= '__LAST__'
else
if has('win32')
call inputsave()
let spath .= input(
\ 'Load this session: ',
\ fnamemodify(v:this_session, ':t'),
\ 'custom,startify#session_list_as_string') | redraw
call inputrestore()
else
let spath .= '__LAST__'
endif
call inputsave()
let spath .= input(
\ 'Load this session: ',
\ fnamemodify(v:this_session, ':t'),
\ 'custom,startify#session_list_as_string') | redraw
call inputrestore()
endif
if filereadable(spath)

View file

@ -742,10 +742,12 @@ Use `:SSave!` or `:SDelete!` to always overwrite or delete an existing session.
*startify-:SLoad*
>
:SLoad [session]
:SLoad[!] [session]
<
Load a session. If you don't specify a session name, it will either prompt you
for one (Windows) or load the last used session (Unix).
Load a session. If you don't specify a session name, it will prompt you for
one.
If the `!` is given, it tries to source the last used session (only Unix).
Providing only a part of the session name works too, if you complete the
argument with either <c-d> or <tab> afterwards.

View file

@ -56,7 +56,7 @@ function! s:on_vimleavepre()
endif
endfunction
command! -nargs=? -bar -complete=customlist,startify#session_list SLoad call startify#session_load(<f-args>)
command! -nargs=? -bar -bang -complete=customlist,startify#session_list SLoad call startify#session_load(<bang>0, <f-args>)
command! -nargs=? -bar -bang -complete=customlist,startify#session_list SSave call startify#session_save(<bang>0, <f-args>)
command! -nargs=? -bar -bang -complete=customlist,startify#session_list SDelete call startify#session_delete(<bang>0, <f-args>)
command! -nargs=0 -bar SClose call startify#session_close()