dccsillag / magma-nvim

Interact with Jupyter from NeoVim.
GNU General Public License v3.0
977 stars 49 forks source link

Handle get_pty_slave failure gracefully #90

Open parsiad opened 1 year ago

parsiad commented 1 year ago

Inside neovim, the command

:python3 from ueberzug.process import get_pty_slave; import os; print(get_pty_slave(os.getppid()))

outputs None. On an arbitrary terminal, it returns the correct pts path.

I haven't looked into why this occurs, but a simple fix is to fail gracefully in this case instead of firing an assertion.

WhiteBlackGoose commented 1 year ago

Hi, thanks for the PR. How does it affect the usage of the plugin? :sweat_smile:

Just to understand the issue being solved

WhiteBlackGoose commented 1 year ago

Oh, I see #92

phcerdan commented 11 months ago

Please merge @WhiteBlackGoose , _get_char_pixelsize is used as a hint, returning None is good enough, no need to throw.

I am facing this issue even when vim.g.magma_image_provider="kitty". Testing this PR locally and ImageOutputChunk is properly displayed. Before this I was getting the assert failure.

For context, I have ueberzug installed in my system python, and magma was failing with this error always, except when opening nvim inside a virtual environment WITHOUT ueberzug (because the function _get_char_pixelsize returned None earlier, before hitting the assert). In the venv without ueberzug, the image was displayed correctly.