folke / persistence.nvim

💾 Simple session management for Neovim
Apache License 2.0
591 stars 26 forks source link

bug: prefix-dot (e.g.: .env, .conf) files stay in the session although buffer was deleted before quitting #25

Closed criuss closed 1 year ago

criuss commented 1 year ago

Did you check docs and existing issues?

Neovim version (nvim -v)

0.9

Operating system/version

linux

Describe the bug

When opening any file with dot prefix these files get restored every time although the buffer was removed before saving the session.

Steps To Reproduce

  1. open .env file
  2. quit nvim and save the session
  3. open and restore the session
  4. delete the buffer with .env file
  5. quit nvim and save the session
  6. open nvim and restore the sesssion

Expected Behavior

.env file should not be restored

Repro

No response

skoch13 commented 1 year ago

I'm facing the very same issue. Similar behavior happened once diffView was previously opened.

folke commented 1 year ago

How do you load persistence? On the BufReadPre event? If so then that's of course normal. Persistence will never have been loaded and as such will also never have saved the session.

skoch13 commented 1 year ago

How do you load persistence? On the BufReadPre event? If so then that's of course normal. Persistence will never have been loaded and as such will also never have saved the session.

If that matters I use it in scope of LazyVim default configuration, while pressing C in Alpha menu

folke commented 1 year ago

In LazyVim, session saving also only starts when you start editing a file

skoch13 commented 1 year ago

It used to work for me, but something happened and it currently does not. Pleasee see the video attached link

edit: it also worth mentioning that the .zshrc file that opens in the 'last session' obviously does not belong to the cwd

folke commented 1 year ago

Seems to be caused by adding globals to session options. I added that a while back to support pinned tabs in bufferline. Willl see what's causing that

folke commented 1 year ago

Now I can't reproduce it anymore. Very weird. Can you manually delete the session and see if the problem vanishes?

skoch13 commented 1 year ago

Should I simply erase the contents of ~/.local/state/nvim/sessions ?

folke commented 1 year ago

That, or just the file of the directory you were testing with

skoch13 commented 1 year ago

STR:

  1. Wiped the contents of sessions folder
  2. Opened another file, made changes, saved
  3. Opened and changed .zshrc
  4. Quit, restore -> .zshrc popping up
folke commented 1 year ago

It's normal that .zshrc is back on step 4? Or did you remove the buffer in step 3?

skoch13 commented 1 year ago

I'd expect both of these changed buffers will be opened in the session, but .zshrc opens on session restore action Screenshot2023-05-22 at 17 17 37

folke commented 1 year ago

@skoch13 so you have the opposite problem of op?

You open two files, then quit, open, and restore only shows one file?

(saving files makes no difference for persistence)

folke commented 1 year ago

persistence saves the session on VimLeavePre, so it's possible that another autocmd errors and that persistence will never save

skoch13 commented 1 year ago

I think I have related issue, because I did not open .zshrc file at all in the last session, but it gets restored.

criuss commented 1 year ago

just tested it again (with the latest lazyvim version) ... i was able to reproduce it with an existing session file and using :wq (quiting via <leader>qq worked) after deleting the session file i was not able to reproduce the error again

skoch13 commented 1 year ago

Lately I solely use the latter qq shortcut. I’ll wipe sessions once again as you suggest.

Thank you for taking a look into it.

folke commented 1 year ago

Must have something todo with that globals sessionopts. Maybe due to an issue with Neovim or some other extension. The fact that I also can no longer reproduce it, after wiping session, probably means it has been fixed in the meantime.

criuss commented 1 year ago

thank you for your time @folke i'll close the issue as it is not reproducible anymore