macvim-dev / macvim

Vim - the text editor - for macOS
https://macvim.org
Vim License
7.47k stars 680 forks source link

Restore original buffer sizes when window is resized #1319

Closed schveiguy closed 1 year ago

schveiguy commented 1 year ago

Is your feature request about something that is currently impossible or hard to do? Please describe the problem. I have a 4k monitor attached to my MBP. When I wake my MBP by typing in my password, for a few seconds, all windows are on my MBP screen, and then the secondary screen awakens, and all the windows that were on that screen are restored to that screen.

This causes any windows that wouldn't fit on the MBP screen to shrink temporarily, and then re-expand to the original size. For MacVim, this means any buffers on the bottom might be squished up, and then when expanded, the bottom buffers take up the extra space, and middle buffers that might have been squished stay squished. In this way, moving a window between screens with different resolutions cause an odd visual, and this is more annoying than problematic.

Describe the solution you'd like An idea I had was that if the window size is shrunk to the point where middle buffers are compressed in size, MacVim remembers the original size of those buffers, and then if the window size is expanded before any other actions are taken, then the middle buffers are expanded instead of just the bottom buffer. This should cover the case. Maybe even if no layout changes have happened (like buffers added/removed or resized)

Describe alternatives you've considered I currently just do ctrl+w= to equalize all windows.

Additional context The following screenshot shows a 4-buffer window on my 4k: Screen Shot 2022-10-18 at 2 03 37 PM

The next screenshot shows what happens when it is moved to the retina display:

Screen Shot 2022-10-18 at 2 03 49 PM

And finally, when it comes back, note how the bottom buffer receives all the expanded space.

Screen Shot 2022-10-18 at 2 03 56 PM

ychin commented 1 year ago

This seems like a decent idea but it should really be filed against Vim itself. MacVim is just a GUI for Vim and this kind of functionality is more core Vim functionality.

FWIW you can set up an autocmd to listen for VimResized and just call windcmd = in the handler. I don't think there's an option to resize the windows proportionally when resizing though.

schveiguy commented 1 year ago

I did so: https://github.com/vim/vim/issues/11406

I suppose this can be closed.