Skip to content
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

Closing Yazi while renaming causes the "Invalid buffer id" error #594

Closed
sxyazi opened this issue Dec 2, 2024 · 3 comments · Fixed by #595
Closed

Closing Yazi while renaming causes the "Invalid buffer id" error #594

sxyazi opened this issue Dec 2, 2024 · 3 comments · Fixed by #595

Comments

@sxyazi
Copy link

sxyazi commented Dec 2, 2024

I occasionally get this error:

Error executing vim.schedule lua callback: .../ika/.local/share/nvim/lazy/yazi.nvim/lua/yazi/utils.lua:356: Invalid buffer id: 1163
stack traceback:
	[C]: in function 'nvim_buf_call'
	.../ika/.local/share/nvim/lazy/yazi.nvim/lua/yazi/utils.lua:356: in function <.../ika/.local/share/nvim/lazy/yazi.nvim/lua/yazi/utils.lua:355>
	[C]: in function 'wait'
	...eovim/0.10.2_1/share/nvim/runtime/lua/vim/lsp/client.lua:758: in function <...eovim/0.10.2_1/share/nvim/runtime/lua/vim/lsp/client.lua:747>
	[C]: in function 'pcall'
	...-lsp-file-operations/lsp-file-operations/will-rename.lua:21: in function 'getWorkspaceEdit'
	...-lsp-file-operations/lsp-file-operations/will-rename.lua:49: in function 'callback'
	....local/share/nvim/lazy/yazi.nvim/lua/yazi/lsp/rename.lua:15: in function 'file_renamed'
	...azi.nvim/lua/yazi/event_handling/yazi_event_handling.lua:76: in function 'process_events_emitted_from_yazi'
	/Users/ika/.local/share/nvim/lazy/yazi.nvim/lua/yazi.lua:72: in function 'on_exit'
	...re/nvim/lazy/yazi.nvim/lua/yazi/process/yazi_process.lua:55: in function <...re/nvim/lazy/yazi.nvim/lua/yazi/process/yazi_process.lua:41>

It's not always reproducible and only happens when I quickly close Yazi and go back to nvim after triggering a rename.

Since I use noice.nvim, it appears in the top right corner of the UI, blocking part of the content, which is a bit annoying.

I think a simple fix would be to check if the buffer ID is still valid using nvim_buf_is_valid before calling vim.api.nvim_buf_call, just in case. It's more like a safety check and wouldn't break anything existing.

@mikavilpas
Copy link
Owner

Nice catch, I don't think I have seen this myself. I'll add that check and let's see if it can be avoided 👍🏻

@mikavilpas
Copy link
Owner

By the way, I think it's possible to configure noice.nvim to have the popups displayed at the bottom right instead of the top right. I had this setting before https://github.com/folke/snacks.nvim was added to lazyvim (which I use). That changed the way it should be done.

It looks like without snacks.nvim I did it like this, and right now (with snacks.nvim) I do it like this

If you like the idea, it might reduce the amount of annoying messages that cover your work 🙂

@sxyazi
Copy link
Author

sxyazi commented Dec 2, 2024

Cool, definitely check it out, and thanks for the fix!

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 a pull request may close this issue.

2 participants