3rd / image.nvim

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

fix: corruption in large images when using ssh #158

Closed SigmaRichards closed 2 months ago

SigmaRichards commented 2 months ago

Potential fix for #95 . When using ssh, larger images have a chance of corrupting and displaying base64 strings as opposed to rendering the image. Through some testing, adding a sleep call to write_graphics seems to fix this issue. Earlier testing showed that it could still occur, but for some time I haven't run into this issue at all.

Hoping to get some feedback on whether this fixes the issue for anyone else.

Issue can be recreated by using ssh localhost as this still uses direct-mode. Then, attempting to render a large image (threshold varies from 30kb to 1mb) will sometimes cause base64 text to be displayed instead of the image. Config settings max_width = nil, max_height = nil, max_width_window_percentage = math.huge and max_height_window_percentage = math.huge minimize the chance that the image will be resized below the byte threshold for corruption.

SigmaRichards commented 2 months ago

I've updated to use vim.uv instead. My understanding is that it's only available for neovim v0.10, so to ensure compatibility I added a check first. Is working on the two versions of neovim I checked:

There's additionally many other places that use vim.loop, however, figured changing those might require additional testing, or perhaps checking how to handle versioning.

3rd commented 2 months ago

This is great, thank you @SigmaRichards !