Skip to content

Commit

Permalink
Merge pull request #83: Don't leave behind empty tab page when :Appen…
Browse files Browse the repository at this point in the history
…dTabSession is unsuccessful
  • Loading branch information
xolox committed Jun 17, 2014
2 parents 1f576c1 + f7845fa commit 8e124c9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -246,7 +246,7 @@ Recently this plug-in switched from reimplementing [:mksession][mksession] to ac
<!-- Start of generated documentation -->

The documentation of the 34 functions below was extracted from
1 Vim scripts on June 17, 2014 at 21:34.
1 Vim scripts on June 17, 2014 at 21:38.

### Public API for the vim-session plug-in

Expand Down
21 changes: 18 additions & 3 deletions autoload/xolox/session.vim
Expand Up @@ -4,7 +4,7 @@
" Last Change: June 17, 2014
" URL: http://peterodding.com/code/vim/session/

let g:xolox#session#version = '2.4.10'
let g:xolox#session#version = '2.4.11'

" Public API for session persistence. {{{1

Expand Down Expand Up @@ -542,12 +542,15 @@ function! xolox#session#open_cmd(name, bang, command) abort " {{{2
if empty(name)
let name = xolox#session#prompt_for_name('restore')
endif
if name != ''
if name == ''
return -1
else
let starttime = xolox#misc#timer#start()
let path = xolox#session#name_to_path(name)
if !filereadable(path)
let msg = "session.vim %s: The %s session at %s doesn't exist!"
call xolox#misc#msg#warn(msg, g:xolox#session#version, string(name), fnamemodify(path, ':~'))
return 0
elseif a:bang == '!' || !s:session_is_locked(path, a:command)
let oldcwd = s:nerdtree_persist()
call xolox#session#close_cmd(a:bang, 1, name != xolox#session#find_current_session(), a:command)
Expand All @@ -566,6 +569,7 @@ function! xolox#session#open_cmd(name, bang, command) abort " {{{2
call xolox#misc#msg#info("session.vim %s: Opened %s %s session from %s.", g:xolox#session#version, session_type, string(name), fnamemodify(path, ':~'))
endif
endif
return 1
endfunction

function! xolox#session#view_cmd(name) abort " {{{2
Expand Down Expand Up @@ -729,8 +733,19 @@ endfunction
function! xolox#session#append_tab_cmd(name, bang, count, command) abort " {{{2
try
call xolox#session#change_tab_options()
let original_tabpage = tabpagenr()
execute printf('%stabnew', a:count == -1 ? '' : a:count)
call xolox#session#open_cmd(a:name, a:bang, a:command)
let status = xolox#session#open_cmd(a:name, a:bang, a:command)
if status <= 0 && empty(bufname(''))
tabclose
if tabpagenr() != original_tabpage
execute original_tabpage . 'tabnext'
endif
if status == 0
" Switching tab pages cleared the warning message. Repeat it now.
call xolox#misc#msg#warn(get(g:xolox_messages, -1, ''))
endif
endif
finally
call xolox#session#restore_tab_options()
endtry
Expand Down
2 changes: 1 addition & 1 deletion doc/session.txt
Expand Up @@ -490,7 +490,7 @@ might take a while...)
Function reference ~

The documentation of the 34 functions below was extracted from 1 Vim scripts on
June 17, 2014 at 21:34.
June 17, 2014 at 21:38.

-------------------------------------------------------------------------------
*public-api-for-vim-session-plug-in*
Expand Down

0 comments on commit 8e124c9

Please sign in to comment.