-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,46 @@ import ( | |
"fmt" | ||
"os" | ||
"os/exec" | ||
|
||
"github.com/junegunn/fzf/src/util" | ||
) | ||
|
||
func isMintty345() bool { | ||
return util.CompareVersions(os.Getenv("TERM_PROGRAM_VERSION"), "3.4.5") >= 0 | ||
} | ||
|
||
func needWinpty(opts *Options) bool { | ||
if os.Getenv("TERM_PROGRAM") != "mintty" { | ||
This comment has been minimized.
Sorry, something went wrong. |
||
return false | ||
} | ||
if isMintty345() { | ||
/* | ||
See: https://github.com/junegunn/fzf/issues/3809 | ||
"MSYS=enable_pcon" allows fzf to run properly on mintty 3.4.5 or later, | ||
however `--height` option still doesn't work, so let's just disable it. | ||
We're not going to worry too much about restoring the original value. | ||
This comment has been minimized.
Sorry, something went wrong.
Konfekt
Contributor
|
||
*/ | ||
if os.Getenv("MSYS") == "enable_pcon" { | ||
This comment has been minimized.
Sorry, something went wrong.
Konfekt
Contributor
|
||
opts.Height = heightSpec{} | ||
return false | ||
} | ||
|
||
// Setting the environment variable here unfortunately doesn't help, | ||
// so we need to start a child process with "MSYS=enable_pcon" | ||
// os.Setenv("MSYS", "enable_pcon") | ||
return true | ||
} | ||
if _, err := exec.LookPath("winpty"); err != nil { | ||
return false | ||
} | ||
if opts.NoWinpty { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
return false | ||
} | ||
return true | ||
} | ||
|
||
func runWinpty(args []string, opts *Options) (int, error) { | ||
sh, err := sh() | ||
if err != nil { | ||
|
@@ -20,6 +58,17 @@ func runWinpty(args []string, opts *Options) (int, error) { | |
} | ||
argStr += ` --no-winpty --no-height` | ||
|
||
if isMintty345() { | ||
return runProxy(argStr, func(temp string) *exec.Cmd { | ||
cmd := exec.Command(sh, temp) | ||
cmd.Env = append(os.Environ(), "MSYS=enable_pcon") | ||
cmd.Stdin = os.Stdin | ||
cmd.Stdout = os.Stdout | ||
cmd.Stderr = os.Stderr | ||
return cmd | ||
}, opts, false) | ||
} | ||
|
||
return runProxy(argStr, func(temp string) *exec.Cmd { | ||
cmd := exec.Command(sh, "-c", fmt.Sprintf(`winpty < /dev/tty > /dev/tty -- sh %q`, temp)) | ||
cmd.Stdout = os.Stdout | ||
|
There might obviously be others, but Windows Terminal is the new Windows standard and works fine, whereas mintty is the Git Bash standard, so I think this suffices