3rd / image.nvim

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

fix: don't re-render all images all the time #141

Closed benlubas closed 2 months ago

benlubas commented 3 months ago

While trying to render a 'large' quantity of images (like, 12+), I noticed insanely bad performance, and suspected something exponentially bad was happening. Took me a while to remember that we chain re-render images, and well, i don't think it's technically exponential, but it's much worse than it could be.

This change quickly fixes the issue for images with inline but without with_virtual_padding. However, the problem persists for padded images. I left a TODO with a potential fix, but it would take a little more time than I have before I go to sleep. I'll probably do it tomorrow night instead of paying attention to class :P

benlubas commented 3 months ago

Wait. do we even need to re-render like this anymore?

benlubas commented 3 months ago

I don't think that we need that code anymore since the change that made all images stick to their extmarks with an auto command.

Let me know if you have a usecase for it still and I can improve it's performance, otherwise I'll just remove it.

benlubas commented 3 months ago

okay 12am brain speaking, there's a fair chance that they're not redundant. I'll look at this again in the morning when I'm not about to fall asleep. Will mark this as a draft for now

benlubas commented 3 months ago

Pretty sure it's needed if a user re-renders an image with different geometry. So this should be the fix.

3rd commented 2 months ago

Thank you again @benlubas <3