Did you check the docs and existing issues?
Neovim version (nvim -v)
NVIM v0.10.0-dev-2064+g2f9ee9b6c
Operating system/version
arch, ubuntu
Describe the bug
Hi!
All buffers from the session .json file are marked as loaded: false when exiting neovim by closing the terminal window instead of executing :qa!.
Is my understanding that at least 1 of the buffers from that .json file should be marked as loaded: true for everything to work correctly later on load, right? I believe that is the case because this is the root of a problem I'm having and which is kinda painful to fully replicate.
What is the severity of this bug?
tolerable (can work around it)
Steps To Reproduce
Using the provided repro, open neovim nightly with nvim --clean +'so repro.lua'.
Put at least 2 files (of any type) under the same cwd as your repro.
- Open a new instance of your terminal emulator.
- Open neovim with
nvim --clean +'so repro.lua'
- Open some files and exit neovim with
:qa!
- Go to the "dirsession" folder (should be on
~...resession_issue/.repro/data/nvim/dirsession/_session_file.json) and inspect the .json file, at least 1 of the buffers is marked as loaded. This is good.
- Now repeat step 3 but this time exit neovim by closing your terminal emulator window (I tested this with Kitty and Konsole)
- Inspect the
.json file again. Now all buffers are marked as unloaded. Bad (I think)
This doesn't seems to cause that much of a problem, until you have some complicated lazy-loading on your neovim config.
My workaround is using "UILeave" event instead of "VimLeavePre":
vim.api.nvim_create_autocmd("UILeave", {
desc = "Save a dir-specific session when you close Neovim",
group = vim.api.nvim_create_augroup("resession_autosave_session", { clear = true }),
callback = function()
-- Only save the session if nvim was started with no args
resession.save(vim.fn.getcwd(), { dir = "dirsession", notify = false })
end,
})
Expected Behavior
At least 1 buffer should be marked as loaded
Directory structure
.
├── file-1.md
├── file-2.md
└── repro.lua
Repro
-- DO NOT change the paths
local root = vim.fn.fnamemodify("./.repro", ":p")
root = root:sub(-1) == "/" and root or root .. "/"
-- 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
--------------------------------------------------------------------------------
vim.g.mapleader = " "
--------------------------------------------------------------------------------
local plugins = {
{
"stevearc/resession.nvim",
event = "VeryLazy",
config = function(_, opts)
local resession = require("resession")
resession.setup(opts)
vim.api.nvim_create_autocmd("VimLeavePre", {
desc = "Save a dir-specific session when you close Neovim",
group = vim.api.nvim_create_augroup("resession_autosave_session", { clear = true }),
callback = function()
-- Only save the session if nvim was started with no args
resession.save(vim.fn.getcwd(), { dir = "dirsession", notify = false })
end,
})
end,
},
}
--------------------------------------------------------------------------------
local lazypath = root .. "/plugins/lazy.nvim"
---@diagnostic disable-next-line: undefined-field
if not (vim.uv or vim.loop).fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable",
lazypath,
})
end
vim.opt.runtimepath:prepend(lazypath)
require("lazy").setup(plugins, {
root = root .. "/plugins",
})
Did you check the bug with a clean config?
Did you check the docs and existing issues?
Neovim version (nvim -v)
NVIM v0.10.0-dev-2064+g2f9ee9b6c
Operating system/version
arch, ubuntu
Describe the bug
Hi!
All buffers from the session
.jsonfile are marked asloaded: falsewhen exiting neovim by closing the terminal window instead of executing:qa!.Is my understanding that at least 1 of the buffers from that
.jsonfile should be marked asloaded: truefor everything to work correctly later on load, right? I believe that is the case because this is the root of a problem I'm having and which is kinda painful to fully replicate.What is the severity of this bug?
tolerable (can work around it)
Steps To Reproduce
Using the provided repro, open neovim nightly with
nvim --clean +'so repro.lua'.Put at least 2 files (of any type) under the same cwd as your repro.
nvim --clean +'so repro.lua':qa!~...resession_issue/.repro/data/nvim/dirsession/_session_file.json) and inspect the.jsonfile, at least 1 of the buffers is marked as loaded. This is good..jsonfile again. Now all buffers are marked as unloaded. Bad (I think)This doesn't seems to cause that much of a problem, until you have some complicated lazy-loading on your neovim config.
My workaround is using "UILeave" event instead of "VimLeavePre":
Expected Behavior
At least 1 buffer should be marked as loaded
Directory structure
.
├── file-1.md
├── file-2.md
└── repro.lua
Repro
Did you check the bug with a clean config?
nvim -u repro.luausing the repro.lua file above.