-
-
Notifications
You must be signed in to change notification settings - Fork 53
[BUG] :SessionSave
doesn't actually accept an argument
#257
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
Comments
Thanks for the issue submission! I'm adding this to the v2.1.0 milestone, hoping to get a few bug fixes as well as some requested features added in that version. Hoping I can get to it soon! |
Wonderful, I'm looking forward to the update! |
Hello, is there any update about this issue? I'm running:
and it returns:
I'm sure that once it worked, I've been using the above command for a long time, but till last year. I'm on Windows 11 Pro. |
#257 [BUG] :SessionSave doesn't actually accept an argument
Latest referenced merge should fix this. |
Just pulled the latest changes. :SessionSave ~/my/custom/path " saves or creates a session in the specified directory path. There doesn't appear to be any completion on the |
@Chloe-H Reopening and will check it out whenever I have some time |
Excellent, I appreciate it! |
Hello, I just wished to ask if there is any update about this. If I do this on Windows 11:
then, the following file is created:
so, the output path is wrong. |
@rmagatti I would also add that this test has been done with the latest commit. |
@rmagatti This reproduces for me (where everything passed to
is Is being able to specify a custom session directory something that's useful for folks? If it's really desired, what about having a second optional argument to SessionSave/Restore that would be the custom session directory to use? That way the code doesn't have to try derive what's intended as it would be clearly specified |
I believe being able to always pass a path to a session file or a dir is desired.
We can identify that with the I think this is how this has worked in the past but changes over the past while likely broke this behaviour. |
Yes, I also think that it worked like that in the past. Overall, it seems like a good idea to allow users to specify a path to a session file or a directory. The only thing I would pay a little attention to is the management of Windows paths (unfortunately with other plugins it often happens that the only ones to be managed correctly are Unix-like paths). Instead, perhaps it could be arranged so that with the commands:
These are just ideas, happy to discuss them with you. |
To help me understand what i think the best option is, I spent some time digging into how the code works currently (tested on default session dir:
auto-session/lua/auto-session/init.lua Line 1095 in 4b07287
Fixing that trivial bug, it will then only restore as expected. I'm not sure what the expected behavior would be if the first argument could possibly be a custom session directory. I would expect Continuing the testing of how it currently works:
auto-session/lua/auto-session/init.lua Lines 1099 to 1103 in 4b07287
Fixing that simple bug then causes it to load the session correctly (also now in PR #324). So what to make of all of this? My takeaway is that because session names are usually paths, it's ambiguous to treat the argument to For me, the more important use case is the ability to save/restore a session consistently, either an automatically created one or an explicitly named one, which means a call to Being able to specify a custom session directory is a secondary use case that should be enabled but not at the cost of disrupting the primary use case of specifying a session name. With all of that in mind, if it were up to me, I would have
As is probably obvious, the implementation of Lastly, if folks were ok with this proposal, I'm happy to put the PR together. Would be a good chance to leverage the unit tests I've been making. And thanks to everyone that made it this far! |
I've read your proposal @cameronr. Makes perfect sense to me, much better than what we have currently and what I've proposed 🤝 |
Great, I'll add to my list to work on! |
@rmagatti I think this can be closed now |
Describe the bug
According to the README, an argument can be supplied to
:SessionSave
to specify a different "directory path" in which to create or save the current session. In reality, it produces one of two errors when an argument is supplied::SessionSave "~/my/custom/path"
(double quotes around the argument) results inError executing Lua callback: vim/_editor.lua:341: nvim_exec2(): Vim(mksession):E190: Cannot open "<default sessions directory>" for writing
(identical to the error described here).:SessionSave '~/my/custom/path'
(single quotes around the argument) results inE488: Trailing characters
.:SessionSave ~/my/custom/path
(no quotes around the argument) also results inE488: Trailing characters
.To Reproduce
Expected behavior
:SessionSave ~/custom/directory/
- Save the current session in~/custom/directory/
with the default session name:SessionSave ~/custom/directory/custom_session_name
- Save the current session in~/custom/directory/
with the namecustom_session_name
:SessionSave custom_session_name
- Save the current session in the default/configured location with the namecustom_session_name
Screenshots
The errors:

Baseline (please complete the following information):
set sessionoptions?
:sessionoptions=blank,buffers,curdir,folds,help,tabpages,winsize,terminal
URL to your current config (if public)(it's private)nvim --version
:On Windows 10 Pro:
On RHEL 7.9:
Additional context
I've revisited #51 with lit candles and holy beads in the hopes of getting the functionality I expect. The workaround there is inspiring. I like auto-session a lot, even with this little bug.
The text was updated successfully, but these errors were encountered: