stevearc / resession.nvim

A replacement for mksession with a better API
MIT License
175 stars 13 forks source link

Error on console when using the git auto session save on close #13

Closed midoBB closed 8 months ago

midoBB commented 1 year ago

When using this exact config

local function get_session_name()
  local name = vim.fn.getcwd()
  local branch = vim.fn.system("git branch --show-current")
  if vim.v.shell_error == 0 then
    return name .. branch
  else
    return name
  end
end
vim.api.nvim_create_autocmd("VimEnter", {
  callback = function()
    -- Only load the session if nvim was started with no args
    if vim.fn.argc(-1) == 0 then
      resession.load(get_session_name(), { dir = "dirsession", silence_errors = true })
    end
  end,
})
vim.api.nvim_create_autocmd("VimLeavePre", {
  callback = function()
    resession.save(get_session_name(), { dir = "dirsession", notify = false })
  end,
})

For Neovim 0.9.1 I get this error message on exiting nvim : src/unix/core.c:116: uv_close: Assertion !uv__is_closing(handle)' failed.

I think it's related to this core issue.

Is there anyway to fix this?

stevearc commented 1 year ago

ah, I mean...it sounds like there's a workaround you can apply by putting a vim.cmd("sleep 10") after the shell command. The only real fix for this is fixing it in core. Another workaround could be periodically polling and caching the current branch, then on exit you could just use the cached branch name instead of running a shell command.