Skip to content

Commit 8e124c9

Browse files
committed
Merge pull request #83: Don't leave behind empty tab page when :AppendTabSession is unsuccessful
2 parents 1f576c1 + f7845fa commit 8e124c9

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ Recently this plug-in switched from reimplementing [:mksession][mksession] to ac
246246
<!-- Start of generated documentation -->
247247

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

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

autoload/xolox/session.vim

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
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
569573
endfunction
570574

571575
function! xolox#session#view_cmd(name) abort " {{{2
@@ -729,8 +733,19 @@ endfunction
729733
function! 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

doc/session.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ might take a while...)
490490
Function reference ~
491491

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

495495
-------------------------------------------------------------------------------
496496
*public-api-for-vim-session-plug-in*

0 commit comments

Comments
 (0)