olimorris / persisted.nvim

๐Ÿ’พ Simple session management for Neovim with git branching, autoloading and Telescope support

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug] flash of previous buffer session is autorestored

akinsho opened this issue ยท comments

commented

Hi,

Been looking into replacing my current session plugin so I can better replicate the https://github.com/emacs-dashboard/emacs-dashboard by listing my sessions and was also looking for something that handled git branches nicely which this does.

One rather frustrating issue I've encountered though is that when auto-restoring a session there is a brief flicker as either my start screen or the first empty buffer is briefly shown before it then auto restores the session. I've tried to get used to it but the flicker is maddening unfortunately.

I had a look through the code and compared it with things like autosession and possession.nvim etc. and noticed the cause I believe to be the line below.

vim.schedule(function()

When this plugin restores a session it uses vim.schedule rather than executing the command immediately which means it defers it and vim the loads the start buffer (or the dashboard) before eventually getting to the autorestore causing the flicker. I can see that removing the scheduling does make it instantaneous but there is a brief flicker since the first autorestore should not happen whilst vim is still starting up but should be delayed till VimEnter I believe.

Any chance you'd be up for changing how auto restoration is handled to avoid the flicker? is it something that you've seen? I'm a bit surprised no one else has mentioned this in the closed issues AFAICT

commented

๐Ÿ‘‹๐Ÿผ @akinsho!

You've raised a really good point here. Historically, the vim.schedule existed due to the issues encountered in #12. At least that was our remedy for it at the time.

I can see that removing the scheduling does make it instantaneous but there is a brief flicker since the first autorestore should not happen whilst vim is still starting up but should be delayed till VimEnter I believe.

I'll explore some options tonight for how this can be resolved and this is really helpful. Also, always open to PRs.

commented

@olimorris much appreciated. I'll definitely be revisiting this eventually as my sanity is going ๐Ÿคฃ, but I've just had someone open like 5 issues on a repo of mine so think that's going to be the rest of my free time this week ๐Ÿ˜ž (guess it karma as I've opened these two on your repo ๐Ÿ˜†)