Skip to content

Conversation

@ChrisMcD1
Copy link

This is reproduced when clicking and dragging over a link, which is a common way that people try to select them to copy.

Partially fixes jesseduffield/lazygit#5057

Copy link
Collaborator

@stefanhaller stefanhaller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, the change makes sense to me, just a small suggestion below.

I suspect the reason this is only a partial fix is due to how we detect mouse drag events in tcell_driver.go (the logic around the MAYBE_DRAGGING state). This is because with the legacy terminal protocol there are no mouse-up events, so we have to poll the button states, which is not really reliable. I'm not sure this really explains the issue (which I can't reproduce with ghostty btw), but I don't have time to investigate this in more depth right now.

Anyway, tcell now supports the kitty protocol for better terminal events, which will make it possible to actually receive real mouse-up events. Hopefully this will make it more reliable. I'm working on upgrading tcell, and will look into this as part of that work. Unfortunately it's a lot more work than I originally anticipated, so it will take a while.

gui.go Outdated
}

if ev.Key == MouseLeft && !v.Editable && g.openHyperlink != nil {
if ev.Key == MouseLeft && ev.Mod != ModMotion && !v.Editable && g.openHyperlink != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we say (ev.Mod & ModMotion) != 0 instead? It's a bit mask.

(It's true that we currently don't include any other bits for mouse events, but this might change in the future.)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point on being a bitmask, although I tested that we want it == 0 instead of != 0. Implemented!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yes of course.

This is reproduced when clicking and dragging over a link, which is a
common way that people try to select them to copy
@ChrisMcD1 ChrisMcD1 force-pushed the multiple-hyperlinks-while-moving branch from 66928bf to b67a047 Compare December 8, 2025 02:35
@stefanhaller stefanhaller merged commit 02ab34c into jesseduffield:master Dec 14, 2025
1 check passed
@stefanhaller
Copy link
Collaborator

@ChrisMcD1 In case you are wondering about bumping the gocui dependency in lazygit: no need for that, I'm working on other changes to gocui right now and will bump it soon anyway.

@stefanhaller
Copy link
Collaborator

@ChrisMcD1 I decided to make a separate PR for bumping the gocui dependency after all; my other changes might take longer, and also this makes it get its own change log entry. #5133

stefanhaller added a commit to jesseduffield/lazygit that referenced this pull request Dec 22, 2025
Update our gocui dependency, which brings in the fix that was made
there; see jesseduffield/gocui#86.

(Fix by `Chris McDonnell <c.a.mcdonn@gmail.com>`)
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.

links have awful user experience

2 participants