vim-session icon indicating copy to clipboard operation
vim-session copied to clipboard

cmd-q quit from macvim -> session lock file leftover

Open delackner opened this issue 11 years ago • 6 comments

If you have let g:session_autosave = 'yes'

in your .vimrc, everything is fine.

Otherwise, cmd-q lags for about half a second and the session lock file remains.

delackner avatar Jul 03 '14 05:07 delackner

I use Gvim with let g:session_autosave = 'yes'. When I quit by ":wq" command, session lock file is still there and I must delete it manually.

SuperBo avatar Nov 23 '14 10:11 SuperBo

I assume that a regular :CloseSession command invocation does successfully remove the lock file? In that case I'm not sure what's going on here...

I've looked through the MacVim documentation but can't find anything that specifically mentions non default behavior of the VimLeavePre and VimLeave automatic command events, and I can't think of any other reasons why automatic commands should fail when the regular commands work fine.

One other thing I can think of is that MacVim triggers the VimLeavePre command differently from other Vim implementations, maybe because of the whole "single instance" thing Mac OS X and MacVim have going on?

xolox avatar Dec 03 '14 21:12 xolox

At least for me this additionally leaves swap files for opened files as if the editor crashed (it doesn't seem to crash though, as per dtruss). This makes vim-session a bit problematic to use. I've tried mhinz/vim-startify which can also save the current session upon close and it works fine with cmd-q, so its code might have some hints.

kjyv avatar Feb 28 '16 20:02 kjyv

I'm in the same situation with @SuperBo, GVim, with this configuration

" Session
" -------
set sessionoptions-=options
set sessionoptions-=help
let g:session_autoload='yes'
let g:session_default_to_last=1
let g:session_autosave='yes'
let g:session_autosave_periodic=10
let g:session_persist_colors=0

The lock file doesn't get removed.

jaalzateolaya avatar Mar 15 '16 14:03 jaalzateolaya

running au VimLeavePre shows:

--- Auto-Commands ---
fugitive_commit  VimLeavePre
    COMMIT_EDITMSG
              execute s:sub(s:FinishCommit(), '^echoerr (.*)', 'echohl ErrorMsg|echo \1|echohl NONE')
PluginSession  VimLeavePre
    *         call xolox#session#auto_save()
              call xolox#session#auto_unlock() 

:q with gvim -V10 --nofork:

Executing QuitPre Auto commands for "\*"
autocommand call s:QuitPreHook(expand('\<amatch\>', 1))
chdir(controllers)
fchdir() to previous dir
Executing BufWinLeave Auto commands for "\*"
autocommand execute getwinvar(+bufwinnr(+expand('\<abuf\>')), 'fugitive_leave')
Executing BufWinLeave Auto commands for "\*"
autocommand if s:can_diffoff(+expand('\<abuf\>')) && s:diff_window_count() == 2 |   call s:diffoff_all(getbufvar(+expand('\<abuf\>'), 'git_dir')) | endif
Executing WinEnter Auto commands for "\*"
autocommand call s:Highlight_Matching_Pair()
Executing BufEnter Auto commands for "\*"
autocommand if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
Writing viminfo file "/home/alexander-programmer/.viminfo"

VimLeavePre is supposed to run before writing viminfo file, right?

Running :call xolox#session#auto_unlock() manually works as expected.

jaalzateolaya avatar Mar 15 '16 16:03 jaalzateolaya

I've been using vi and vim forever (30 years), but only recently learned about sessions -- they're great! I've got about 30 files open in various tabs and split screens for my current project. I can't figure out how to close a session (maybe :q on every open file?) without leaving old swp files and a session lock. So when I open it again, it takes like five minutes to clear all the warnings. Am I doing something wrong, or is this the bug people are talking about here? Might it be fixed? Is there a work-around? @kvyv mentioned vim-startify -- I could try that.

Waitaminit -- @xolox 's 12/3/2014 comment saved me... If I do :CloseSession, :OpenSession instead of using the MavVim menu versions of these, it seems to work ok.

Sigfried avatar Mar 31 '17 14:03 Sigfried