folke / persistence.nvim

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

bug: /tmp/git-blob-SMwKCw/<filename.py> appears in buffer list #40

Closed lbrtdy closed 7 months ago

lbrtdy commented 7 months ago

Did you check docs and existing issues?

Neovim version (nvim -v)

v0.9.4

Operating system/version

Debian

Describe the bug

After using LazyVim distribution for a while with multiple files loaded in the buffer and splits being used to display 2 files side by side, I quit Neovim and relaunch. Upon restoring the session by pressing the "s" hotkey, I noticed that this temp file takes up one of the splits. The other split is occupied by the actual file that this temp file is for. My buffer is sometimes cleared such that only these 2 files are listed despite having more files when quitting Neovim originally.

This issue is not 100% reproducible. I do encounter it multiple times a day due to me restoring sessions so much.

Steps To Reproduce

  1. Launch LazyVim Neovim distribution
  2. Create a vertical split with <leader> w |
  3. Load a bunch of files into the buffer via <leader> <leader>
  4. Quit Neovim with :qa
  5. Launch Neovim
  6. Restore session with s at landing page

Expected Behavior

Session is restored such that splits contain the correct files and the buffer contains list of previous files.

Actual Behavior

WindowsTerminal_oGy0nmuyMB

lbrtdy commented 7 months ago

Found the cause. I have git configured to use nvimdiff as a diff/merge tool when doing git difftool. Git generates a temp file to use in the ORIGINAL split and the file itself in the CHANGED split. Exiting this diff session causes the temp file path to be saved and restored the next time, thus resulting in a blank file.

This is not a bug. I suppose it could be a feature request to not auto-save sessions when neovim is invoked as a difftool.