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: Scrolling of windows with winbar or native borders #2165
fix: Scrolling of windows with winbar or native borders #2165
Conversation
I fixed a couple of issues with terminal buffers. The Neovim documentation does not seem to reflect what's actually sent. |
f776736
to
43177f6
Compare
match kind_str.as_str() { | ||
"ui" => kind = Some(HighlightKind::Ui), | ||
"syntax" => kind = Some(HighlightKind::Syntax), | ||
// The documentation says terminal but Neovim 0.9.4 sends term... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there an issue to link here?
} else { | ||
String::default() | ||
}; | ||
// hi_name can actually be absent for terminal, even though the documentation indicates otherwise |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
Looks good to me. Ship it ✅ |
I tested this and it works for simple case like |
@cshuaimin, yes I should have put that in the description, it's a known problem and we discussed it on Discord. But the highlight groups are the only thing we have to detect the borders and winbars. Neovim simply does not provide us with any other info. Through the UI protocol. For the winbar we could maybe make an even more hacky solution and listen to the option being set, both the global and window window local ones, and infer if there's a winbar or not in a given window based on that. But the floating borders can also use arbitrary highlight groups and that same hack does not work for them, since there's no way to listen for a window configuration change. I will open a discussion on the Neovim repo, so that we can get a proper solution for Neovim 0.10. |
That makes sense, thanks for the explanation. Float window border works well, great! |
I greatly appreciate the recent work of @fredizzimo. I want to say thanks at this point. For this PR, I don't think it is ready for a merge. With the change, when using a winbar content that is more complex than something like A partial fix for the issue should not come with a downside for cases like @cshuaimin is mentioning or for users that use things like dropbar. The fix is not working there anyway atm. Unfortunately - as the PR description already mentions - this again requires that upstream neovim allows for a proper fix. |
Hm.. this should be strictly better than main in all cases, winbars with custom highlight groups the bug should be the same as on main, and the content scrolls with the content like @cshuaimin explains, I can't quite explain the different highlights in the screenshot above. But maybe the highlight groups are dynamically updated, and in that case the If it does, there's no more hacks I can think of to get this work, and we will have to get a fix Neovim itself. Maybe we could merge this with the option set to false, to allow people to still have proper border and winbar scrolling with simple winbars and borders. |
Good suggestion, I unfortunately cannot test it today anymore. I'll leave an update tomorrow. |
@fredizzimo the option has no effect on the mentioned behavior. |
@ttytm, I think I need a Neovim configuration, so that I can re-produce the problem myself. Ideally following this format https://github.com/neovim/neovim/blob/master/contrib/minimal.lua But if that is not possible, a complete |
Hey @fredizzimo sorry bout the delay. I don't have the capacity atm to create a minimal repro. It's very unfortunate as I don't like to be a blocking factor. I can share a full nvim config where this happens with: https://github.com/tenxsoydev/nxvim. |
The documentation seem to be wrong on a couple of points...
d206834
to
f2b7ec7
Compare
@ttytm, I tested your configuration, and I can repeat the problems with the winbar highlights getting brighter when telescope is opened. But I can also repeat that on the current master, so there must be something else going on here, mabye some earlier PR that broke it. In any case, I will try to make this more robust by comparing the content instead of using highlight groups. We know how many lines are scrolled, and from that we see which lines stay in place. If it works, it should not take long to implement, so I'm putting this as draft until then. I also tested without this ce0174a, but the same thing, so it's something earlier. |
I'm discovering that it might not be a problem with Neovide but a problem with the config. Edit: Edit2: |
I'm moving this out of draft again. The content based approach has too many special cases, and I'm not confident that it can be reliable enough. My idea was basically to check how many lines have stayed in place at the top and bottom, every time the screen is updated, and consider those borders or winbars, which are treated the same way in this PR. The biggest issue with that approach is duplicate lines, but also lines that changes due to highlight updates and stuff like that, or winbars with dynamic content. So instead I think we can go with what we have, perhaps even with But I'm leaving it enabled by default for now, until I get more feedback. |
}) | ||
}) | ||
}) | ||
.all(|v| v); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.all(|v| v); | |
.any(|v| v); |
lines with purly border highlight groups are considered borders.
I believe if we change this to "lines contain border highlight groups are considered borders", then dropbar.nvim will work! Don't know if this has false positives. @fredizzimo what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However with this change, it seems that we need another way to ignore left and right borders.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a great idea!
We could use all to detect the borders and any to detect winbars. I will try that later today.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I implemented this, and it does seem to work.
But I have only done a very quick test yet and it's a bit late for me to do more testing now.
I will also make a bit more efficient implementation later.
8abd998
to
dc6ccca
Compare
Thank you! Choooooooooooo choooooooooooo 🚂 |
What kind of change does this PR introduce?
This fixes the scrolling of windows with winbar or native borders by only scrolling the inner region.
The solution is quite hacky, see the new
neovide_unlink_border_highlights
option for example. But I think this is the best we can do with the current version of Neovim.I also changed
Arc<Mutex<Line>>
<RC<RefCell<Line>>
because it's never accessed concurrently.NOTE: This probably needs a bit more testing before merging.
Did this PR introduce a breaking change?