44" Last Change: June 17, 2014
55" URL: http://peterodding.com/code/vim/session/
66
7- let g: xolox #session#version = ' 2.4.10 '
7+ let g: xolox #session#version = ' 2.4.11 '
88
99" Public API for session persistence. {{{1
1010
@@ -542,12 +542,15 @@ function! xolox#session#open_cmd(name, bang, command) abort " {{{2
542542 if empty (name)
543543 let name = xolox#session#prompt_for_name (' restore' )
544544 endif
545- if name != ' '
545+ if name == ' '
546+ return -1
547+ else
546548 let starttime = xolox#misc#timer#start ()
547549 let path = xolox#session#name_to_path (name)
548550 if ! filereadable (path )
549551 let msg = " session.vim %s: The %s session at %s doesn't exist!"
550552 call xolox#misc#msg#warn (msg, g: xolox #session#version , string (name), fnamemodify (path , ' :~' ))
553+ return 0
551554 elseif a: bang == ' !' || ! s: session_is_locked (path , a: command )
552555 let oldcwd = s: nerdtree_persist ()
553556 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
566569 call xolox#misc#msg#info (" session.vim %s: Opened %s %s session from %s." , g: xolox #session#version , session_type, string (name), fnamemodify (path , ' :~' ))
567570 endif
568571 endif
572+ return 1
569573endfunction
570574
571575function ! xolox#session#view_cmd (name) abort " {{{2
@@ -729,8 +733,19 @@ endfunction
729733function ! xolox#session#append_tab_cmd (name, bang , count , command ) abort " {{{2
730734 try
731735 call xolox#session#change_tab_options ()
736+ let original_tabpage = tabpagenr ()
732737 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
734749 finally
735750 call xolox#session#restore_tab_options ()
736751 endtry
0 commit comments