-
-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AutoSave ignores current loaded session when there's multiple local cwd's #45
Comments
I see. This is an interesting one, the plugin currently doesn't keep track of the cwd itself but uses whatever is set at the time of session saving, which explains the issue but solving it might not be trivial. I'll give it some more thought before actioning this. Thanks for the submission! |
Keep track of last loaded session. Closes #45
@rmagatti this issue started happening again after latest changes with cwd, even with |
@rmagatti any clue what could have broken this? local HOME = vim.fn.expand('$HOME')
require('auto-session').setup({
log_level = 'error',
auto_session_enable_last_session = false,
auto_session_enabled = true,
auto_save_enabled = true,
auto_restore_enabled = true,
auto_session_suppress_dirs = { '/etc', '/tmp', HOME, HOME .. '/code' },
pre_save_cmds = { 'lua require("interface").win.close_plugin_owned()' },
cwd_change_handling = false,
})
-- lua/interface.lua
-- Close plugin owned windows.
interface.win.close_plugin_owned = function()
-- Jump to preview window if current window is plugin owned.
if interface.win.is_plugin_owned(0) then
vim.cmd([[ wincmd p ]])
end
for _, win in ipairs(fn.getwininfo()) do
if interface.win.is_plugin_owned(win.bufnr) then
-- Delete plugin owned window buffers.
api.nvim_buf_delete(win.bufnr, {})
end
end
end
-- Detect if window is owned by plugin by checking buftype.
interface.win.is_plugin_owned = function(bufid)
local origin_type = api.nvim_buf_get_option(bufid, 'buftype')
if origin_type == '' or origin_type == 'help' then
return false
end
return true
end |
Not quite yet. I'll have to do some digging, just haven't had the time lately unfortunately. |
@rafi can you set the log_level to |
I think i have similar problem. I use cwd in monorepo but I don't want sessions saved under each package/service which is happening now. I need session saved only in the folder that I opened with, which is usually root of monorepo |
@kuba-gaj, Auto Session uses the cwd to derive the session from. So if you're switching cwds within a monorepo the behaviour you're seeing makes sense given how the plugin currently works. That said I suppose there could be a setting to allow for storing what session was initially loaded in memory, and save only that session. This would have to be carefully coded though as to not break things like rmagatti/session-lens. |
Re-produce: Create two directories and start a session in cd ~
mkdir tmp && cd $_
mkdir a b
touch a/a.txt b/b.txt
cd a
nvim Now open a file, and create a new tab with different :e a.txt
:tabnew
:lcd ../b
:e b.txt
:qall Now run Expected: Open session with the same exact tabs, one whose Specially when |
Problem: After leaving Neovim when on a tab with a different local cwd than the restored session's name, session is saved as the cwd name, and not the current loaded session.
Expected: If a session is loaded (or has been restored), Autosave should save the loaded session name from
v:this_session
, regardless of the local cwd.Reproduce:
nvim
, open a few files and close Neovim to save the session.nvim
again, session should be restored.:tabnew
and:lcd ~/different/project
and open a file from the other project.v:this_session
for the current loaded session.The text was updated successfully, but these errors were encountered: