stevearc / resession.nvim

A replacement for mksession with a better API
MIT License
220 stars 15 forks source link

fix: restore window cursor pos after setting size #57

Closed AThePeanut4 closed 4 months ago

AThePeanut4 commented 4 months ago

This fixes an issue I was running into where the cursor position of open buffers would not get restored properly.

The easiest way to reproduce is to open a file where the length of the file is at least a couple times longer than the window height. Then scroll down all the way to the bottom, create/save a session, and exit Neovim. If you then reopen Neovim and load the session, you should see that the cursor is in the wrong place (for me, it always is at line 45).

Edit: this is happening because I've set splitkeep=screen (because I'm using https://github.com/folke/edgy.nvim) - setting it back to the default splitkeep=cursor also fixes the issue. A more complicated fix would be to temporarily set splitkeep=cursor while loading the window layout, but just reordering the operations achieves the same thing and is simpler.

stevearc commented 4 months ago

LGTM thanks for the PR!