zefei / vim-wintabs

Modern buffer manager for Vim
MIT License
325 stars 25 forks source link

Ability to *undo* closing of a window. #10

Closed jordwalke closed 6 years ago

jordwalke commented 7 years ago

This plugin is tremendously helpful. It would be nice if it could work well together or have the functionality baked into wintabs. Currently it doesn't work with wintabs. https://github.com/AndrewRadev/undoquit.vim

zefei commented 7 years ago

wintabs stores a list of "local" buffers to each window, so it's unlikely I can re-use any code from undoquit. That being said, undo closing buffer/window/tab sounds like a great feature to have. I'll look into it when I have time.

jordwalke commented 7 years ago

Thank you for considering the feature, and thanks for this wonderful plugin.

Bountysource

jordwalke commented 6 years ago

Did you give any thought to this? Have you found the need for such a feature in your day to day use? Once you get use to undoquit, it's hard to loose the feature.

jordwalke commented 6 years ago

I was thinking that 90% of the value could be gotten from only supporting the use case of one undo level - the ability to revert the most recently closed wintab, regardless of which window it was closed from.

zefei commented 6 years ago

I've thought about this and would implement it as undo closing buffers without considering window and vimtab configurations, just like what you suggested. I haven't got the time yet, but will do it in the next round of clean ups (a few bugs and documentation).

zefei commented 6 years ago

This is implemented in the last commit, please check it out!

jordwalke commented 6 years ago

Very cool can’t wait to check it out

jordwalke commented 6 years ago

I think the only thing remaining here is to track which "approximate window" the tab was closed from. Was it the last open tab in a window that resulted in the window closing? If so, then a new window should probably be opened (it's hard to restore the exact window position of course but some simple setting could configure how new windows are opened if not instructed specifically (vert/horiz)).

If it was closed from a window that is still open, then it should probably reappear in that window it was removed from.

Either way, this is still a nice feature as it is.

zefei commented 6 years ago

Opening in original window is doable, it requires giving windows unique ids, which isn't too hard. It however is a bit too jumpy to my taste: e.g. I really hate how Chrome undoes closed tabs inside different windows. I'll think about what's the best next step here after some other features.

jordwalke commented 6 years ago

I think one compromise is to only "Undo Close" within the same tab. WintabsUndo would then undo the closing of the most recent buffer/window in the currently focused tab. That's not as jarring as jumping to a completely different tab to undo the close. Jumping to another tab would feel like jumping to another Chrome window to undo the close. If you can accept that, then you might want to keep track of the most recently closed buffer on a per-tab basis.

zefei commented 6 years ago

I decided not doing window scoped undo for now as it involves some unnecessarily challenging edge cases. I added some commands to move buffer across windows. That combined with current undo should be able to satisfy most use cases. I'm closing this but please open another issue if these two are not enough for your workflow.