-
Notifications
You must be signed in to change notification settings - Fork 49
bug: E5108 "Invalid buffer" whe toggle the render #260
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
The problem still exists even with my modification, it is way less frequent but I particularly see it in DiffView ing the MD files. Note In DiffView ing, the ft is still markdown |
At some point, we need to add a |
Experimenting with : function M.set_all(enabled)
-- Attempt to attach current buffer in case this is from a lazy load
M.attach(util.current('buf'))
state.enabled = enabled
for _, buf in ipairs(buffers) do
if vim.api.nvim_buf_is_valid(buf) then
ui.update(buf, vim.fn.bufwinid(buf), 'UserCommand', true)
end
end
end at
seems promising, it wont render DiffVeiw MD files at all though |
## Details Issue: #260 When logging info at the buffer level we get the file name for the buffer to make the logs more useful. However if the buffer is invalid this call to get file name will throw an exception. Wrap the call to get file name in a check that buffer is valid. Return some default string if it is not. Other parts of the ui.update flow will validate the buffer and window and prevent any actual changes to invalid buffers.
Thanks for letting me know! This should resolve it: 0022a57 Error is getting triggered on this line here: https://github.com/MeanderingProgrammer/render-markdown.nvim/blob/main/lua/render-markdown/core/ui.lua#L79, since logging things at the buffer level calls Once that no longer causes a problem the very next line: https://github.com/MeanderingProgrammer/render-markdown.nvim/blob/main/lua/render-markdown/core/ui.lua#L80, checks that the buffer and window are both valid and does an early return if either is not. |
You're awesome |
Neovim version (nvim -v)
0.10.2
Neovim distribution
My own
Operating system
Ubuntu
Terminal emulator / GUI
Alacritty
Describe the bug
When several markdown files are opened and some of them are modified with or without writing , toggling the renderer can cause this error log :
I looked a little in the source code and it seems the autocmd at
render-markdown.nvim/lua/render-markdown/manager.lua
Line 18 in e41b000
is registered in all files and if somehow there is a temporary buffer that comes into existence and is wiped out right after (maybe another plugin is doing it) is queued in the plugin internals
I changed autocmd to
And it seems to be working, I see this autocmd is intentionally registered for all the files but maybe there is a better way of doing it
Expected behavior
no invalid buffer error
Healthcheck output
Plugin configuration
Plugin error log
Error 04:11:20 PM msg_show.emsg E5108: Error executing lua: ...y/render-markdown.nvim/lua/render-markdown/core/util.lua:131: Invalid buffer id: 4
stack traceback:
[C]: in function 'nvim_buf_get_name'
...y/render-markdown.nvim/lua/render-markdown/core/util.lua:131: in function 'file_name'
...zy/render-markdown.nvim/lua/render-markdown/core/log.lua:61: in function 'buf'
...azy/render-markdown.nvim/lua/render-markdown/core/ui.lua:79: in function 'update'
...azy/render-markdown.nvim/lua/render-markdown/manager.lua:47: in function 'set_all'
...im/lazy/render-markdown.nvim/lua/render-markdown/api.lua:17: in function 'toggle'
/home/sadegh/.config/nvim/lua/helpers.lua:47: in function </home/sadegh/.config/nvim/lua/helpers.lua:44>
Confirmations
Additional information
No response
The text was updated successfully, but these errors were encountered: