lazygit icon indicating copy to clipboard operation
lazygit copied to clipboard

Mouse hover follows delta Hyperlinks

Open mayorbyrne opened this issue 1 year ago • 3 comments

Describe the bug I'm seeing some unintended behavior with regards to hyperlinks in delta. They work as expected on first click, but after that it appears to follow every link by simply hovering over the hyperlink.

To Reproduce

  1. I click a hyperlink in a diff, which opens the file in the editor
  2. close the file
  3. Now simply hovering over a link in the diff opens the file again
  4. This behavior appears to resolve itself after the terminal window loses focus

Expected behavior Hyperlinks should only be followed on an actual mouse click.

Version info: commit=, build date=, build source=homebrew, version=0.44.1, os=darwin, arch=arm64, git version=2.39.5 (Apple Git-154) git version 2.39.5 (Apple Git-154)

Additional context I'm using the suggested config

git:
  paging:
    colorArg: always
    pager: delta --dark --paging=never --line-numbers --hyperlinks --hyperlinks-file-link-format="lazygit-edit://{path}:{line}"

Screen Recording of the issue

lazygit

mayorbyrne avatar Sep 20 '24 13:09 mayorbyrne

Are you using WezTerm? I tried to reproduce this with all the terminal emulators that I could find on my machine, and only WezTerm showed this behavior. It works fine in Terminal.app, iTerm, Kitty, Alacritty, and VS Code's integrated terminal.

I think this is a bug in WezTerm. What seems to happen is that WezTerm sends the mouse-down event to lazygit, and then lazygit suspends to the background in order to launch vim; the mouse-up event is never seen by lazygit. Then, after lazygit resumes, the mouse-move events that WezTerm sends to lazygit still contain the "mouse-button-1-is-pressed" flag. That's the bug.

stefanhaller avatar Oct 09 '24 16:10 stefanhaller

I am experiencing a similar issue with deltas hyperlinks. Additionally when I hover over Files pane the selection highlight changes to where the mouse is hovering. Quitting lazygit and starting over again seems to remember the hover state. I only get rid of it after clicking on anywhere in lazygit that is not a hyperlink.

Windows Terminal: 1.23.12811.0 lazygit: commit=80223c7fbbd0b86631a988834cbe88e267bb0bd9, build date=2025-11-01T09:43:19Z, build source=binaryRelease, version=0.56.0, os=windows, arch=amd64, git version=2.51.2.windows.1

config.yml

git:
  pagers:
    - externalDiffCommand: "... lazygit-pager.bat"

lazygit-pager.bat

@echo off

set "old=%~2"
set "new=%~5"
set "target=%~1"
set "old=%old:\=/%"
set "new=%new:\=/%"

git --no-pager diff --no-index --no-ext-diff "%old%" "%new%"^
 | sed -e "s|%old%|%target%|g" -e "s|%new%|%target%|g"^
 | delta --width=%LAZYGIT_COLUMNS% --dark --paging=never --hyperlinks --hyperlinks-file-link-format="lazygit-edit://{path}:{line}"

kaarel-sm avatar Nov 12 '25 14:11 kaarel-sm

@kaarel-sm It sounds like your version of Windows Terminal has the same bug then. I just tried it on my Windows machine, and couldn't reproduce the issue though. Can you tell me how to find out the version of Windows Terminal that I'm using? I'm not a Windows user, and I couldn't find it.

Quitting lazygit and starting over again seems to remember the hover state.

Yeah, this seems to confirm that it's the terminal's fault; I don't see how we can do much about it in lazygit.

@mayorbyrne You never got back to me for the question I asked above. What terminal are you using?

stefanhaller avatar Nov 12 '25 15:11 stefanhaller