3rd / image.nvim

🖼️ Bringing images to Neovim.
MIT License
811 stars 35 forks source link

Document integration clears user added images in markdown files #102

Closed benlubas closed 6 months ago

benlubas commented 6 months ago

This was brought to my attention in https://github.com/benlubas/molten-nvim/issues/109 by @V3RGANz

If a user adds an image to a markdown document (via the API, not by adding ![](...)), the document integration will cleanup those images when the document changes, or when the users creates a new split window (and possibly on other events as well). The integration doesn't put these images back.

This is one area of code that we found that leads to this problem.

https://github.com/3rd/image.nvim/blob/master/lua/image/utils/document.lua#L46-L73

Specifically this part, which assumes that all images attached to the window/buffer belong to the image.nvim document integration.

https://github.com/3rd/image.nvim/blob/master/lua/image/utils/document.lua#L46-L49

A solution of the top of my head is to have the document integration (and all integrations) keep track of their own list of managed images. I can go ahead and open a PR if that seems like a good solution @3rd

3rd commented 6 months ago

Yes, definitely made that assumption, I'll push a fix in a few hours!

3rd commented 6 months ago

Should be ok now https://github.com/3rd/image.nvim/commit/ec577441edca399c43d77b522870dbd7b9cd38b8

benlubas commented 6 months ago

Perfect thank you!