AndrewRadev / undoquit.vim

Undo a :quit -- reopen the last window you closed
https://www.vim.org/scripts/script.php?script_id=5725
MIT License
64 stars 4 forks source link

windows closed by commands such as `<c-w>c` #6

Closed Konfekt closed 9 years ago

Konfekt commented 9 years ago

The undoclosewin.vim plugin also restores windows closed by commands such as <c-w>c or ZZ. Is it outside of the scope of undoquit.vim or is it impossible to implement this reliably ?

If not, how about allowing undoquit to undo closes of windows by such commands as well (perhaps by taking a look at undoclosewin.vim's implementation) ?

AndrewRadev commented 9 years ago

From what I see, undoclosewin uses a different method. I'll see what I can do.

AndrewRadev commented 9 years ago

Hmm, undoclosewin seems to work in a more complicated way than I expected. It listens to the BufWinLeave event, but that one gets fired even when you're editing a new buffer in the same window :/. I guess this is why the internals of the plugin do some duplicate checks, although I'm not so sure how reliable they end up being...

Either way, this would be pretty complicated to support, so I think I won't implement it. In my experiments, ZZ works fine, it's only <c-w>c that doesn't throw a QuitPre autocommand. One way to get this working for you would be to remap <c-w>c:

nnoremap <c-w>c :call undoquit#SaveWindowQuitHistory()<cr><c-w>c

This seems to work for me, but I wouldn't put it in the plugin, since I don't want to override someone's mappings. Maybe I'll write it down as a tip in the documentation.