See if using vim.schedule() when doing some stuff will fix the weirdness
parent
abeb001d5f
commit
f312ae146a
|
|
@ -58,7 +58,6 @@ function M.load(opts)
|
||||||
config.load_post()
|
config.load_post()
|
||||||
end
|
end
|
||||||
M.fire("LoadPost")
|
M.fire("LoadPost")
|
||||||
vim.api.nvim_notify("Session Loaded\n" .. session, vim.log.levels.OFF, {})
|
|
||||||
return true -- returning deletes autocmd after fired
|
return true -- returning deletes autocmd after fired
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
@ -127,7 +126,6 @@ function M.save(opts)
|
||||||
if type(config.save_post) == "function" then
|
if type(config.save_post) == "function" then
|
||||||
config.save_post()
|
config.save_post()
|
||||||
end
|
end
|
||||||
vim.api.nvim_notify("Session Saved", vim.log.levels.OFF, {})
|
|
||||||
M.fire("SavePost")
|
M.fire("SavePost")
|
||||||
return true -- returning true deletes autocmd after fired
|
return true -- returning true deletes autocmd after fired
|
||||||
end,
|
end,
|
||||||
|
|
@ -137,8 +135,10 @@ function M.save(opts)
|
||||||
if type(config.save_pre) == "function" then
|
if type(config.save_pre) == "function" then
|
||||||
config.save_pre()
|
config.save_pre()
|
||||||
end
|
end
|
||||||
vim.api.nvim_command("wa")
|
vim.schedule(function()
|
||||||
vim.api.nvim_command("mksession! " .. e(opts.session or vim.g.persisting_session or M.current()))
|
vim.api.nvim_command("wa")
|
||||||
|
vim.api.nvim_command("mksession! " .. e(opts.session or vim.g.persisting_session or M.current()))
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
---Delete the current session
|
---Delete the current session
|
||||||
|
|
@ -172,12 +172,14 @@ function M.switch(session_file_path)
|
||||||
vim.api.nvim_create_autocmd("User", {
|
vim.api.nvim_create_autocmd("User", {
|
||||||
pattern = "PersistedSavePost",
|
pattern = "PersistedSavePost",
|
||||||
callback = function()
|
callback = function()
|
||||||
for _, buf in ipairs(vim.api.nvim_list_bufs()) do
|
vim.schedule(function()
|
||||||
if vim.api.nvim_buf_is_loaded(buf) then
|
for _, buf in ipairs(vim.api.nvim_list_bufs()) do
|
||||||
vim.api.nvim_buf_delete(buf, {})
|
if vim.api.nvim_buf_is_valid(buf) then
|
||||||
|
vim.api.nvim_buf_delete(buf, {})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
M.load({ session = session_file_path })
|
||||||
M.load({ session = session_file_path })
|
end)
|
||||||
return true
|
return true
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue