Skip to content

Commit 8254cff

Browse files
committed
Write correct session lock when (auto-)opening tab-scoped session.
When a tab-scoped session is automatically opened during load (or via the :OpenSession command), the session lock does not contain the 'tabpage' attribute. This causes the auto-save when quitting Vim to fail with "The 'default' session is already loaded in this Vim. Use the command ':SaveTabSession! default' to override." During auto-load (because we cannot know whether the to-be-loaded session is a session-scoped one), we need to update the lock in case of a tab-scoped session _after_ opening the session. Additionally, the s:vim_instance_id() function also needs to consider xolox#session#is_tab_scoped(), as only that is set during (auto-)load; xolox#session#include_tabs() only gives the correct result when one of the :...TabSession commands is invoked.
1 parent d833471 commit 8254cff

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

autoload/xolox/session.vim

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,7 @@ function! xolox#session#open_cmd(name, bang, command) abort " {{{2
560560
call s:lock_session(path)
561561
execute 'source' fnameescape(path)
562562
if xolox#session#is_tab_scoped()
563+
call s:lock_session(path) " Retroactively (this is only known after the session has been loaded) add the tabpage to the lock.
563564
let t:session_old_cwd = oldcwd
564565
let session_type = 'tab scoped'
565566
else
@@ -1022,7 +1023,7 @@ function! s:vim_instance_id()
10221023
if !empty(v:servername)
10231024
let id['servername'] = v:servername
10241025
endif
1025-
if !xolox#session#include_tabs()
1026+
if !xolox#session#include_tabs() || xolox#session#is_tab_scoped()
10261027
let id['tabpage'] = tabpagenr()
10271028
endif
10281029
return id

0 commit comments

Comments
 (0)