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

Periodical error #41

Open Mugworth opened 1 year ago

Mugworth commented 1 year ago

Hello, after just sitting in vim doing some editing i get this error, it does not show that often, but i can't think of the reason why it's showing up.

Error executing vim.schedule lua callback: ...ocal/share/nvim/lazy/hologram.nvim/lua/hologram/init.lua:47: Invalid buffer id: 49                                                                                                        
stack traceback:                                                                                                    
        [C]: in function 'nvim_buf_get_extmarks'                                                                    
        ...ocal/share/nvim/lazy/hologram.nvim/lua/hologram/init.lua:47: in function 'buf_render_images'             
        ...ocal/share/nvim/lazy/hologram.nvim/lua/hologram/init.lua:17: in function <...ocal/share/nvim/lazy/hologram.nvim/lua/hologram/init.lua:17> 

Other than that, plugin works just fine.

lyndhurst commented 9 months ago

I got it working pretty easily too, but I get the same error message. In my case, the message is thrown every time I save the buffer :w<Cr>.

Thanks for your time.

joelpeapen commented 6 months ago

same problem

simonlearnscoding commented 3 months ago

same here if someone knows a fix let me know

TamaMcGlinn commented 1 month ago

I just get a bunch of these errors, and if I ignore them and continue for a while, there seems to be some infinite loop so my whole NeoVim crashes. Adding a check for invalid bufnr is trivial; add the check in lua/hologram/init.lua

function hologram.buf_render_images(buf, top, bot)
  if not vim.fn.bufexists(buf) then
    return
  end
...

but the plugin is still unable to remove images again when I switch to a different buffer. This makes hologram unusable at present.

TamaMcGlinn commented 1 month ago

This PR fixes the issue. For anyone encountering this later, just switch to lucasdf/hologram.nvim to get the fix.