persistence.nvim icon indicating copy to clipboard operation
persistence.nvim copied to clipboard

bug: Persistence uses incorrect directory to save sessions

Open ZyX-II opened this issue 1 year ago • 1 comments

Did you check docs and existing issues?

  • [X] I have read all the persistence.nvim docs
  • [X] I have searched the existing issues of persistence.nvim
  • [X] I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

0.9.5

Operating system/version

Windows 10 21H2

Describe the bug

After https://github.com/folke/persistence.nvim/commit/0361df7775f5b4ed51a6d7fe159438573b7f07a6 persistence started using C:\users\user\scoop\apps\neovide as directory to save every session for because this is the directory I would get when starting neovide (neovim GUI) from Windows task bar and I usually do that and then load either correct session or open file I want (which will trigger changing directories due to autocd-like functionality I have in my init.vim). Older behaviour of using current directory at the time of exit would be preferred.

Steps To Reproduce

  1. Start some neovim GUI from the Windows task bar.
  2. Change directory to the project directory.
  3. Save session.

Expected Behavior

Persistence saves session for the project directory.

Repro

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/persistence.nvim",
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

-- add anything else here

ZyX-II avatar Feb 27 '24 16:02 ZyX-II

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Jul 06 '24 01:07 github-actions[bot]

This got fixed in https://github.com/folke/persistence.nvim/commit/1565ca0af2d93ee94335c2950d92bc133c90aa82 when save() function stopped using cached session name.

ZyX-II avatar Jul 17 '24 18:07 ZyX-II