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

Error executing vim.schedule lua callback #80

Closed
Shatur opened this issue Apr 11, 2022 · 6 comments
Closed

Error executing vim.schedule lua callback #80

Shatur opened this issue Apr 11, 2022 · 6 comments

Comments

@Shatur
Copy link

Shatur commented Apr 11, 2022

After 0d02acf I have the following errors:

|| Error executing vim.schedule lua callback: ...ins/start/nvim-notify/lua/notify/service/buffer/init.lua:75: Invalid buffer id: 3
|| stack traceback:
|| 	[C]: in function 'nvim_buf_delete'
|| 	...ins/start/nvim-notify/lua/notify/service/buffer/init.lua:75: in function <...ins/start/nvim-notify/lua/notify/service/buffer/init.lua:68>
|| Error executing vim.schedule lua callback: ...ins/start/nvim-notify/lua/notify/service/buffer/init.lua:75: Invalid buffer id: 2
|| stack traceback:
|| 	[C]: in function 'nvim_buf_delete'
|| 	...ins/start/nvim-notify/lua/notify/service/buffer/init.lua:75: in function <...ins/start/nvim-notify/lua/notify/service/buffer/init.lua:68>

I use a plugin that closes all currently opened buffers and sources session: https://github.com/Shatur/neovim-session-manager
And if on startup I have some notifications - they will be removed with the error above because of this line:

api.nvim_buf_delete(self._buffer, { force = true })

Could you use nvim_buf_is_valid before calling this to ensure that other plugins or user didn't touch the buffer?

rcarriga added a commit that referenced this issue Apr 11, 2022
@rcarriga
Copy link
Owner

Wrapped it in pcall so should work fine now 😄

@Shatur
Copy link
Author

Shatur commented Apr 11, 2022

It's a bad idea. I would highly recommend you to use nvim_buf_is_valid.

@rcarriga
Copy link
Owner

Why is it a bad idea?

@Shatur
Copy link
Author

Shatur commented Apr 11, 2022

Because it's slower and nvim_buf_is_valid was designed exactly for this case.

@rcarriga
Copy link
Owner

rcarriga commented Apr 12, 2022

it's slower

For something that is run occasionally I don't think that is at all a concern
I'd rather just have the single line of code instead of a conditional

@Shatur
Copy link
Author

Shatur commented Apr 12, 2022

For something that is run occasionally I don't think that is at all a concern

In my case it slowdowns my startup if I have any notification.

I'd rather just have the single line of code instead of a conditional

As to me passing a function into a function is less clear that a regular check, especially if this check is used to prevent specific kind of error you trying to avoid.

But as you say.

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

No branches or pull requests

2 participants