Skip to content

Commit

Permalink
Fix session loading
Browse files Browse the repository at this point in the history
  • Loading branch information
dosimple committed Sep 7, 2022
1 parent 23a3e25 commit dbb0575
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions plugin/workspace.vim
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,25 @@ func! WS_Rename(WS)
call s:remove(t:WS, b)
call s:add(a:WS, b)
endfor
unlet s:ws[t:WS]
let t:WS = a:WS+0
let s:ws[t:WS] = 1
call s:renumber(tabpagenr(), a:WS)
call s:session_var()
endfunc

func! s:renumber(t, n)
let WS = gettabvar(a:t, "WS")
if WS == a:n
return
endif
if has_key(s:ws, a:n)
throw "Workspace exists: " .. a:n
endif
if has_key(s:ws, WS)
unlet s:ws[WS]
endif
call settabvar(a:t, "WS", a:n+0)
let s:ws[a:n] = 1
endfunc

func! s:b(b)
let b = a:b
if type(b) != v:t_dict
Expand Down Expand Up @@ -159,11 +172,12 @@ func! s:session_load()
return
endif
exe "let sv = " .. g:WS_Session
for t in range(1, tabpagenr("$"))
for t in range(tabpagenr("$"), 1, -1)
if t != tabpagenr()
call settabvar(t, "WS", sv.ws[t])
call s:renumber(t, sv.ws[t])
endif
endfor
" To accomodate existing buffers proir
call WS_Rename(sv.ws[tabpagenr()])
for fname in keys(sv.bs)
if ! bufexists(fname)
Expand Down

0 comments on commit dbb0575

Please sign in to comment.