core: handle mouse capture events with link highlighting

Fixes #1416

At a high level, the issue is that when mouse capture is enabled (i.e. in
neovim), "shift" escapes the capture. So "cmd+shift" is equal to "cmd"
which doesn't get sent to the TUI program and so on. For link
highlighting which now requires "cmd" (super) is held, we were sending
"cmd+shift" to the renderer so we weren't checking for links.

So the core of this commit is respecting this scenario and stripping the
shift modifier.

This commit also found that when the mouse wasn't over a link, we were
always checking and highlighting links on line one of the visible
screen. This bug is fixed and should also result in a very slight
performance improvement on rendering in all cases.
This commit is contained in:
Mitchell Hashimoto
2024-02-01 09:13:13 -08:00
parent 61b964b958
commit 6de4533afb
5 changed files with 36 additions and 9 deletions

View File

@@ -36,6 +36,11 @@ pub const Highlight = union(enum) {
/// hovering or always. For always, all links will be highlighted
/// when the mods are pressed regardless of if the mouse is hovering
/// over them.
///
/// Note that if "shift" is specified here, this will NEVER match in
/// TUI programs that capture mouse events. "Shift" with mouse capture
/// escapes the mouse capture but strips the "shift" so it can't be
/// detected.
always_mods: Mods,
hover_mods: Mods,
};