folke / persistence.nvim

💾 Simple session management for Neovim
Apache License 2.0
655 stars 25 forks source link

bug: Persistence uses incorrect directory to save sessions #48

Closed ZyX-II closed 3 months ago

ZyX-II commented 7 months ago

Did you check docs and existing issues?

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
github-actions[bot] commented 3 months ago

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.

ZyX-II commented 2 months ago

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