edluffy / hologram.nvim

👻 A cross platform terminal image viewer for Neovim. Extensible and fast, written in Lua and C. Works on macOS and Linux.
MIT License
1.28k stars 31 forks source link

Handle error on nvim_buf_get_extmarks #26

Open lucasdf opened 1 year ago

lucasdf commented 1 year ago

I am getting this error when closing the autocomplete buffer/popup:

Error executing vim.schedule lua callback: ...te/pack/packer/start/hologram.nvim/lua/hologram/init.lua:47: Invalid buffer id: 7                                                                                                                                                                                        
stack traceback:
        [C]: in function 'nvim_buf_get_extmarks'
        ...te/pack/packer/start/hologram.nvim/lua/hologram/init.lua:47: in function 'buf_render_images'
        ...te/pack/packer/start/hologram.nvim/lua/hologram/init.lua:17: in function <...te/pack/packer/start/hologram.nvim/lua/hologram/init.lua:17>

It seems nvim_buf_get_extmarks can throw an error in case the buffer doesn't exist anymore, so it might be a good idea to skip it in case it throws.