junegunn / fzf

:cherry_blossom: A command-line fuzzy finder
https://junegunn.github.io/fzf/
MIT License
64.3k stars 2.38k forks source link

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

Open ykhan21 opened 3 months ago

ykhan21 commented 3 months ago

Checklist

Output of fzf --version

0.53.0 (c4a9ccd)

OS

Shell

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.

junegunn commented 3 months ago

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

LightRenderer


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