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

[Bug] Recent image.nvim changes throw off image positions by one #197

Open
benlubas opened this issue May 23, 2024 · 5 comments
Open

[Bug] Recent image.nvim changes throw off image positions by one #197

benlubas opened this issue May 23, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@benlubas
Copy link
Owner

There was a change (that I made too, no one to blame but me :P) in image.nvim a little bit ago that changed the way inline images are rendered in relation to their extmarks, they're now rendered one line below instead of on the same line.

Here's the offending line:

3rd/image.nvim@d24d498#diff-90b9887d8ed1bf7a314a020fe9673aacfe3778eac5198d82eafa29f3b2668dc3R153

We just need to throw a -1 in molten somewhere

this was mentioned in the comments of #88

@benlubas benlubas added the bug Something isn't working label May 23, 2024
@benlubas
Copy link
Owner Author

image

Time to take another crack at fixing this bug (in image.nvim)

@MiroPalmu
Copy link

MiroPalmu commented Sep 29, 2024

How is it going with this one?

I don't know if this helps but below is a collection of screenshots of Molten (c4e8260) cells with varying levels of brokenness.
Testing is done on Nvim v0.10.1 using image.vim (c4e8260) with ueberzug (ueberzugpp 2.9.6) backend in foot (1.18.1) terminal.

Cells are displaying objects of class (*):

class rows:
    def __init__(self, rows):
        self.n = rows

    def _repr_latex_(self):
        rows = ""
        for i in range(self.n):
            rows += f"r_{i} \\\\ "
        return f"$\\begin{{matrix}} {rows} \\end{{matrix}}$"

The results seemed to depend on the font size of foot. In the left column foot is left to my defaults and screenshots in the right column are produced by reopening Nvim, increasing the font size and running the cells again.

image

We can see that in the left ones the output can either be completely or partially cut off from the cell output window. On the right in the first two cases outputs are completely missing and in the last three they are visible but too small and in the wrong position.

(*) The optional dependency pnglatex can not display this latex. The problem is related to this issue which I have fixed in my fork of the project. As the project is really small and last update is from 7 years ago, I would advocate to absorb it to Molten as then it could be easily fixed for everyone.

edit. If there is anyway I could help just point me to right direction :)

@benlubas
Copy link
Owner Author

benlubas commented Sep 29, 2024

I would advocate to absorb it to Molten as then it could be easily fixed for everyone

I've had this on my list of things to do for a long time. I agree that asking people to install it is a little crazy when it's not really doing much at all. It's just something that carried over from Magma that I didn't think about until I had less time and motivation to work on this


As far as fixing these other image rendering issues, I'm pretty sure that it's mainly an image.nvim and or neovim bug that's holding back this PR. That said, I think that #201 might be of interest to you. I'd rather have the image.nvim bug fixed but it's obvious that that's going to take a bit of time. So if you want to try #201 and it fixes your issues, I might just merge it

@MiroPalmu

@MiroPalmu
Copy link

I tested the commit from #201 by rebasing it on top of current main branch.

Seems that it fixes the issue for taller images but unfortunately rows(1) still does not work.

fixed_smaller

As what comes to larger font sizes, their position is now fixed but again it seems that only taller images work. However it seems that the font size affects how tall images have to be as larger font hides rows(2).

fixed

Of course there is unrelated issues with large font sizes as the images are not scaled with the font size and changing the font size while nvim will break the images.

@benlubas
Copy link
Owner Author

benlubas commented Oct 5, 2024

small images not showing up is actually not surprising to me. image.nvim will never try to display an image at a resolution larger than it's true resolution.

So if you have a 24x24 image to show, and your cell size is 25x50, image.nvim probably just fails to show the image b/c it's too small.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants