4
4
" Last Change: June 17, 2014
5
5
" URL: http://peterodding.com/code/vim/session/
6
6
7
- let g: xolox #session#version = ' 2.4.10 '
7
+ let g: xolox #session#version = ' 2.4.11 '
8
8
9
9
" Public API for session persistence. {{{1
10
10
@@ -542,12 +542,15 @@ function! xolox#session#open_cmd(name, bang, command) abort " {{{2
542
542
if empty (name)
543
543
let name = xolox#session#prompt_for_name (' restore' )
544
544
endif
545
- if name != ' '
545
+ if name == ' '
546
+ return -1
547
+ else
546
548
let starttime = xolox#misc#timer#start ()
547
549
let path = xolox#session#name_to_path (name)
548
550
if ! filereadable (path )
549
551
let msg = " session.vim %s: The %s session at %s doesn't exist!"
550
552
call xolox#misc#msg#warn (msg, g: xolox #session#version , string (name), fnamemodify (path , ' :~' ))
553
+ return 0
551
554
elseif a: bang == ' !' || ! s: session_is_locked (path , a: command )
552
555
let oldcwd = s: nerdtree_persist ()
553
556
call xolox#session#close_cmd (a: bang , 1 , name != xolox#session#find_current_session (), a: command )
@@ -566,6 +569,7 @@ function! xolox#session#open_cmd(name, bang, command) abort " {{{2
566
569
call xolox#misc#msg#info (" session.vim %s: Opened %s %s session from %s." , g: xolox #session#version , session_type, string (name), fnamemodify (path , ' :~' ))
567
570
endif
568
571
endif
572
+ return 1
569
573
endfunction
570
574
571
575
function ! xolox#session#view_cmd (name) abort " {{{2
@@ -729,8 +733,19 @@ endfunction
729
733
function ! xolox#session#append_tab_cmd (name, bang , count , command ) abort " {{{2
730
734
try
731
735
call xolox#session#change_tab_options ()
736
+ let original_tabpage = tabpagenr ()
732
737
execute printf (' %stabnew' , a: count == -1 ? ' ' : a: count )
733
- call xolox#session#open_cmd (a: name , a: bang , a: command )
738
+ let status = xolox#session#open_cmd (a: name , a: bang , a: command )
739
+ if status <= 0 && empty (bufname (' ' ))
740
+ tabclose
741
+ if tabpagenr () != original_tabpage
742
+ execute original_tabpage . ' tabnext'
743
+ endif
744
+ if status == 0
745
+ " Switching tab pages cleared the warning message. Repeat it now.
746
+ call xolox#misc#msg#warn (get (g: xolox_messages , -1 , ' ' ))
747
+ endif
748
+ endif
734
749
finally
735
750
call xolox#session#restore_tab_options ()
736
751
endtry
0 commit comments