Skip to content

fix: check for invalid buffers from corrupted states#35

Closed
samiulsami wants to merge 1 commit into
iofq:masterfrom
samiulsami:fix-invalid-buffer
Closed

fix: check for invalid buffers from corrupted states#35
samiulsami wants to merge 1 commit into
iofq:masterfrom
samiulsami:fix-invalid-buffer

Conversation

@samiulsami
Copy link
Copy Markdown
Contributor

Fixes the following error, which occurs upon loading a corrupted state/session.
dart nvim_error

Signed-off-by: sami <samiulsami7786@gmail.com>
@iofq
Copy link
Copy Markdown
Owner

iofq commented Nov 15, 2025

Can you explain a bit more about how you're hitting this case? It should only happen if you're trying to restore a Dart session that has a filename in state, but that filename is not currently open as a buffer.

The opening of that filename should be handled by the underlying session provider (mini.sessions, etc.). I'm not sure if we want to have Dart handle opening those files, but we could have it skip files that aren't already open when reading a session.

@samiulsami
Copy link
Copy Markdown
Contributor Author

Ah makes sense. But I'm loading dart's state manually like so:

local cwd_hash = vim.fn.sha256(vim.fn.getcwd())
vim.api.nvim_create_autocmd("VimLeavePre", {
	callback = function()
		dart.write_session(cwd_hash)
	end,
})

vim.api.nvim_create_autocmd("VimEnter", {
	callback = function()
		dart.read_session(cwd_hash)
	end,
})

And have configured my session manager to load only after EVERY other plugin has loaded.

I've usually been hitting this issue when i'm trying to load a session that contains a marked file that i've since deleted.

@iofq
Copy link
Copy Markdown
Owner

iofq commented Nov 16, 2025

Yeah that tracks. I think what we should do in that case is, when loading a session (read_session), remove files from the state that are not currently open.

If you'd like to take a stab at it, be my guest, otherwise I can knock it out this week.

@samiulsami
Copy link
Copy Markdown
Contributor Author

Unfortunately i cant focus on this right now, looking forward to your fix. I'll just use this fork for now and reopen if the issue persists.

@iofq
Copy link
Copy Markdown
Owner

iofq commented Dec 7, 2025

@samiulsami should be fixed in master now

@samiulsami
Copy link
Copy Markdown
Contributor Author

Yep, that fixed it. Thanks!

@samiulsami samiulsami deleted the fix-invalid-buffer branch December 8, 2025 05:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants