-
-
Notifications
You must be signed in to change notification settings - Fork 48
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
[BUG] .swp file, corrupted session, esoteric recovery #337
Comments
Thanks for the detailed report. The main question is how are you exiting nvim with unsaved edits in a swap file? Is it crashing for you or are you exiting in some other way? AFAIK, that should only happen in some significant error situation. As for the error, it's happening while nvim is sourcing the session and happens on the We rely on nvim's builtin handling of sourcing a session file so there isn't much we can do about that error. You can suppress swap file warnings by adding A to shortmess but that may make it harder to know if you have unsaved changes after a crash so only set it if understand the ramifications. Separately, in your auto-session config, return {
{
'rmagatti/auto-session',
dependencies = {
'nvim-telescope/telescope.nvim', -- Only needed if you want to use sesssion lens
},
opts = {
auto_session_suppress_dirs = { '~/', '~/Projects', '~/Downloads', '/' },
auto_session_enable_last_session = true,
auto_save_enabled = true,
auto_restore_enabled = true,
auto_session_use_git_branch = true,
auto_session_create_enabled = function()
local cmd = 'git rev-parse --is-inside-work-tree'
return vim.fn.system(cmd) == 'true\n'
end,
},
config = function(_, opts)
require('auto-session').setup(opts)
local wk = require('wk_mappings')
wk.wk().add(wk.auto_session())
end,
},
} OTOH, if you haven't needed those options, you could also just not set them. Also, |
A small gesture of appreciation for putting in the work and making it freely available
Shutting down my machine, forgetting to save changed buffers. I could probably replicate it by closing the terminal emulator that it's running in as well? Would you like me to confirm these methods?
Didn't realise that. I'm new to lazy.nvim. Thanks. ...from what I gather here, there's not really that much to be done? As I understand things, raw nvim has a process where you can, for example, choose to restore, save the restored state, and that clears the swap file. Perhaps there could be somethnig like a recovery-mode for auto-session? e.g. when something like swap file, corrupted session, etc is detected, auto-session is, in a way, "disabled", giving a chance to go through the recovery process, and then attempt to restart? |
No, that's not necessary. It's easy to reproduce the case by having unsaved changes and then killing the nvim process.
While I wish the native swap recovery process was more streamlined, there isn't much we can currently do in this case beyond reporting the error and disabling autosave (so we don't impact overwrite the session on exit). When it happens, I'd recommend resolving the existing swap error(s) however makes the most sense to you then run |
Actually, I take all of that back. It is possible for us to ignore errors when sourcing the session by doing: silent! source <session> I think that would improve the experience in this case as you'd still get the swap warning (and get to chose an option) but it would continue processing the session. We can even grab I whipped up a test branch if you want to give it a try. You'll have to update your auto-session config as follows: -- 'rmagatti/auto-session',
'cameronr/auto-session',
branch = 'silent-source', After changing the config, you'll have to open Lazy and update the plugin to actually pull it down (and restart nvim just to be sure) |
If you've disabled the autosave feature but are still encountering issues, you can easily resolve the problem by following these simple steps:
By implementing these steps, you should be able to eliminate any lingering issues and continue working on your project without any further disruptions. |
Describe the bug
following error on startup:
coming after this message:
additionally, I use barbar, and it doesn't show up the loaded in buffers.
:bp
and:bn
work, but jumping between numbered buffers doesn't. I'm not familiar enough with barbar to know how this might be relevant at a detailed level, but it supports an hypothesis that the feature of auto-session "reopening" the same buffers is not happening as expected.I run
:recover
after all that, save, and the file is all good file-wise, but session is still corrupted, and need to manually delete the swap file. Once that's done, session opens as expected.If I open a session that isn't corrupted, and try to change to the corrupted session, the old sessions buffers do not close, and a single buffer of the opened session is opened.
this is the sessions file:
To Reproduce
Unknown exactly, but this is my best guess:
Expected behavior
I select a swap-file option (recover, edit anyway, etc), and the session is restored, with the file(s) in question being opened to a buffer accordingly
creenshots to help explain your problem.
Baseline (please complete the following information):
Result of
set sessionoptions?
: sessionoptions=blank,buffers,curdir,folds,help,tabpages,winsize,terminalOS. e.g
uname -a
: Linux LaptopOfTheseus 5.15.0-102-generic #112-Ubuntu SMP Tue Mar 5 16:50:32 UTC 2024 x86_64 x86_64 x86_64 GNU/LinuxNeovim version
nvim --version
❯ nvim --version
NVIM v0.10.1
Build type: Release
LuaJIT 2.1.1713484068
Run "nvim -V1 -v" for more info
URL to your current config (if public)
not present, but here is the table I provide lazy.nvim for setup
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: