fzf icon indicating copy to clipboard operation
fzf copied to clipboard

Windows: Mouse-clicking doesn't work properly in bash

Open ykhan21 opened this issue 1 year ago • 1 comments

Checklist

  • [X] I have read through the manual page (man fzf)
  • [X] I have searched through the existing issues
  • [X] For bug reports, I have checked if the bug is reproducible in the latest version of fzf

Output of fzf --version

0.53.0 (c4a9ccd)

OS

  • [ ] Linux
  • [ ] macOS
  • [X] Windows
  • [ ] Etc.

Shell

  • [X] bash
  • [ ] zsh
  • [ ] fish

Problem / Steps to reproduce

  1. scoop install git fzf
  2. In Git Bash, run ls | fzf
  3. Click on any item on the list. Observe that the item that becomes selected is not what was clicked.

Also, on Wezterm with bash, clicking does not seem to work at all, while on Wezterm with cmd, clicking works.

ykhan21 avatar Jun 10 '24 03:06 ykhan21

There are two renderer implementations for Windows.

  1. FullscreenRenderer. Based on tcell library. We use this in fullscreen mode.
  2. LightRenderer. It was added later to support --height and used only when --height option is given.

FullscreenRenderer

  • Mouse works on cmd.exe
  • Mouse doesn't work on mintty
    • Seems to be a limitation of tcell. https://github.com/gdamore/tcell/issues/133#issuecomment-766434124

LightRenderer

  • Mouse works on cmd.exe
  • Mouse works on mintty, but click position is broken. Fixed in 0684a20ea3da6100cf43c919d1fcfda3644eb8c1

So with 0684a20ea3da6100cf43c919d1fcfda3644eb8c1, mouse works properly when --height is used on mintty, but not in fullscreen mode. We can fix this by always using LightRenderer.

diff --git a/src/terminal.go b/src/terminal.go
index 128da4e..7307c17 100644
--- a/src/terminal.go
+++ b/src/terminal.go
@@ -711,7 +711,7 @@ func NewTerminal(opts *Options, eventBox *util.EventBox, executor *util.Executor
 		}
 	}
 	if fullscreen {
-		if tui.HasFullscreenRenderer() {
+		if !tui.IsLightRendererSupported() {
 			renderer = tui.NewFullscreenRenderer(opts.Theme, opts.Black, opts.Mouse)
 		} else {
 			renderer, err = tui.NewLightRenderer(ttyin, opts.Theme, opts.Black, opts.Mouse, opts.Tabstop, opts.ClearOnExit,

It's a simple change, and I can confirm that it fixes the mouse problem. However, I'm not sure if there are any unwanted side effects. I could use some help testing the binary.

fzf.exe.zip

junegunn avatar Jun 12 '24 12:06 junegunn