OXY2DEV / helpview.nvim

Decorations for vimdoc/help files in Neovim
Apache License 2.0
202 stars 3 forks source link

Bug: Extmarks cleared in one split when a help file is splitted and scrolled #15

Open Bekaboo opened 1 month ago

Bekaboo commented 1 month ago

When a help file is splitted into two windows and one of the window scrolls, the visual effects can be cleared in another window, expect both windows render normally.

I believe this is because helpview clears "off-screen" extmarks but it only considers visible range of the current window instead of all windows that contain the help file.

https://github.com/user-attachments/assets/940a270e-20a8-40c0-ba22-9710d69f4ee6

OXY2DEV commented 1 month ago

There's a few issues here,

  1. There's no clean way to get all the attached windows so the plugin doesn't work well when you have multiple windows with a single buffer.
  2. If the plugin were to render based on all the cursor you would get copies of extmark when their range overlaps which is a problem.

At the moment it's not possible to handle multiple windows. But maybe in the future this can be added.

Bekaboo commented 1 month ago

How about just not to clear off screen extmarks as a workaround?

OXY2DEV commented 1 month ago

That leaves different kinds of edge cases.

If you have something like this in a help file.

>lua
  vim.print("something");
<

If any of the line is within the range of the renderer the entire thing will be rendered.


Let's say, you open the file and started at the bottom of the file and the last line of the code block was in the range.

Then you did gg, this time you went to the top of the file and only the first line of the code block was in the range.

Now, you permanently have 2 extmarks that won't go away unless you manually scroll over them.

This becomes an issue with headings.

Plus some lines in the help file contain a lot of inline elements. They would be duplicated.

And the modeline will also have a lot of duplicate lines.

Bekaboo commented 1 month ago

I see.

There's no clean way to get all the attached windows so the plugin doesn't work well when you have multiple windows with a single buffer.

FYI vim.fn.win_findbuf(bufnr) returns a list of windows that contains the given buffer. I think it's quite clean.