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: match lines added by image.nvim #201

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tszirr
Copy link

@tszirr tszirr commented May 31, 2024

Bugfix

An insufficient number of lines was added to the output buffer for images to place their extmark and virtual lines. This commit always adds one space character and one newline for each image, so that the extmark line sits in front of the image, which is fully placed into virtual lines by image.nvim.

I also modified the lineno to start at 1 in order to account for the leading status line, it would be good to check if this makes sense to you, otherwise I could not make sense of the +1 specifically for images.

@benlubas
Copy link
Owner

What is the bug? Could you maybe include images? I'm not sure I understand. Is it #197 or something else?

b/c 197 requires a fix in image.nvim as well. I have a fix for 197 ready to go, but without the matching fix in image.nvim, it would make the experience in this plugin strictly worse.

@tszirr
Copy link
Author

tszirr commented May 31, 2024

The bug is that no actual line is currently added for images, which results in the lineno passed to image.nvim to point to other output behind it or invalid lines. You can see that with invalid indices, no virtual lines were added before the fix e.g. here (note the ~):
image

With the fix, the virtual lines are properly placed:
image

(note you also need the other PR's fix though to actually see this with proper image refereshes)

@tszirr
Copy link
Author

tszirr commented May 31, 2024

(note that I did not change the values of linenos passed image.nvim, I just moved the offset outside to be more consistent with where the output status line is added at the top)

@benlubas
Copy link
Owner

benlubas commented Jun 1, 2024

I see now, thank you. I think this is just a fix for a side effect of #197, and doesn't actually fix #197. I'd rather address 197 directly, I will put up the branch with my fix, and you can test that it also solves this problem.

@benlubas
Copy link
Owner

benlubas commented Jun 1, 2024

here's the branch with the fix (very simple fix) https://github.com/benlubas/molten-nvim/tree/push-otzqzrqwlkzu

I should note that this fix exposes molten to an image.nvim bug that's existed for a long time now, which is why I haven't merged this yet

@tszirr
Copy link
Author

tszirr commented Jun 1, 2024

Unfortunately just adding -1 does not seem like an effective fix, it just breaks for me in practice:
image

In contrast, with the changes in this PR, the necessary lines to match image.nvim are added and the images show up:
image

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.

2 participants