junegunn / fzf

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

Git Bash Mintty: only use cmd.exe if winpty missing #3811

Closed Konfekt closed 1 month ago

Konfekt commented 1 month ago

Addresses https://github.com/junegunn/fzf/issues/3809

junegunn commented 1 month ago

Thanks. While testing the patch, I have noticed a few things.

junegunn commented 1 month ago

CTRL-C problem is fixed in 303c3bae7ff02996bdbad4b743cdb23c1813a4c6.

Konfekt commented 1 month ago

When fzf is started from Git bash, CTRL-C fails to properly terminate fzf and I get error restoring terminal mode: Input/output error message. I'll look into it

I can't reproduce it with Windows 10, Git Bash 2.42.0 and latest fzf 0.52.1dev (without winpty), neither in Git Bash nor inside Vim in Git Bash. However, exiting, independent of the shortcut, sends an 130 signal. That might be on purpose, though.

We can do this in addition to the patch. What do you think?

I think that's a good idea. My slight adaption tries to keep everything working where winpty is not readily available, say older installs of Git on administered Window work machines, in harmony with the change at the other line.

Let me suggest an additional check for the existence of winpty at 573df52 (#3807) to this end.

junegunn commented 1 month ago

Let me suggest an additional check for the existence of winpty at 573df52 (#3807) to this end.

So what do we do when winpty is not available? I decided to not perform the check and let it fail because I thought fzf wouldn't run it anyway without winpty, but according to the latest discussion in https://github.com/junegunn/fzf/issues/3809#issuecomment-2124893297 that is not necessarily true?

junegunn commented 1 month ago
Konfekt commented 1 month ago

fzf wouldn't run it anyway without winpty, but according to the latest discussion in https://github.com/junegunn/fzf/issues/3809#issuecomment-2124893297 that is not necessarily true?

When I removed winpty on Windows 10 with fzf 0.52.1-dev then :FZF in Vim in Git Bash Mintty with

  elseif has('win32unix') && $TERM_PROGRAM ==# 'mintty' " && !executable('winpty')
    let shellscript = s:fzf_tempname()
    call s:writefile([command], shellscript)
    let command = 'start //WAIT sh -c '.shellscript
    let a:temps.shellscript = shellscript
  endif

the pop up shows

grafik

whereas fzf 0.52.1 works fine.

So it was meant that 0.52.1-dev keeps doing in the absence of winpty on Windows 11 what 0.52.1 did