Skip to content

Commit

Permalink
Make :OpenSession and :CloseSession preserve working directory
Browse files Browse the repository at this point in the history
  • Loading branch information
xolox committed May 12, 2011
1 parent 13c3dd9 commit ae7ba3a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions autoload/xolox/session.vim
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,9 @@ function! xolox#session#open_cmd(name, bang) abort " {{{2
let msg = "%s: The %s session at %s doesn't exist!"
call xolox#misc#msg#warn(msg, s:script, string(name), fnamemodify(path, ':~'))
elseif a:bang == '!' || !s:session_is_locked(path, 'OpenSession')
let oldcwd = getcwd()
call xolox#session#close_cmd(a:bang, 1)
let s:oldcwd = oldcwd
call s:lock_session(path)
execute 'source' fnameescape(path)
unlet! s:session_is_dirty
Expand Down Expand Up @@ -359,6 +361,10 @@ function! xolox#session#close_cmd(bang, silent) abort " {{{2
endif
execute 'enew' . a:bang
unlet! s:session_is_dirty
if exists('s:oldcwd')
execute 'cd' fnameescape(s:oldcwd)
unlet s:oldcwd
endif
if v:this_session == ''
if !a:silent
let msg = "%s: Closed session."
Expand Down
2 changes: 1 addition & 1 deletion plugin/session.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
" Author: Peter Odding
" Last Change: May 12, 2011
" URL: http://peterodding.com/code/vim/session/
" Version: 1.3.9
" Version: 1.3.10

" Support for automatic update using the GLVS plug-in.
" GetLatestVimScripts: 3150 1 :AutoInstall: session.zip
Expand Down

0 comments on commit ae7ba3a

Please sign in to comment.