Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: corruption in large images when using ssh #158

Merged
merged 1 commit into from
Apr 30, 2024
Merged

Conversation

SigmaRichards
Copy link
Contributor

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.

@@ -92,6 +92,7 @@ local write_graphics = function(config, data)
else
control_payload = "m=1"
end
vim.loop.sleep(1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vim.loop is being deprecated, you should use vim.uv instead.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks great otherwise @SigmaRichards

Uses vim.uv, but allows for vim.loop for older versions of nvim
@SigmaRichards SigmaRichards reopened this Apr 30, 2024
@SigmaRichards
Copy link
Contributor Author

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:

  • v0.10.0-dev-3045+gefaf37a2b
  • v0.9.1

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.

@SigmaRichards SigmaRichards marked this pull request as ready for review April 30, 2024 07:41
@3rd
Copy link
Owner

3rd commented Apr 30, 2024

This is great, thank you @SigmaRichards !

@3rd 3rd merged commit 604692f into 3rd:master Apr 30, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants