helix-editor / helix

A post-modern modal text editor.
https://helix-editor.com
Mozilla Public License 2.0
33.64k stars 2.5k forks source link

Suspend (ctrl+z) does not work on Git Bash for Windows (msys2) #6425

Open rcorre opened 1 year ago

rcorre commented 1 year ago

Summary

ctrl+z does not suspend helix when running in Git Bash for Windows (which I think is a fork of MSYS2?). I think this should be possible to implement, as other programs running in git bash/msys2 can be suspended by pressing ctrl+z, including vim.

Reproduction Steps

I tried this: 1. `hx` 2. `ctrl+z` I expected this to happen: Suspend to shell. Instead, this happened: Nothing. ### Helix log
~/.cache/helix/helix.log ``` please provide a copy of `~/.cache/helix/helix.log` here if possible, you may need to redact some of the lines ```
[helix.log](https://github.com/helix-editor/helix/files/11063047/helix.log) ### Platform Windows ### Terminal Emulator wezterm 20230320-124340-559cb7b0 ### Helix Version 22.12-467-g2904a10f
rcorre commented 1 year ago

I found https://superuser.com/a/1486383 which suggested running under winpty. I tried that, and now I can suspend, but it turns my colorscheme hot pink, and when I resume, helix is in a bad/corrupted looking state where I can't really interact with it (keypresses just insert literal text that types over everything, including the UI elements).

rcorre commented 1 year ago

Sending kill -STOP to helix shows 0 [sig] bash 4333! sigpacket::process: Suppressing signal 17 to win32 process (pid 7240).

rcorre commented 1 year ago

So what makes helix a "win32 process" that can't be suspended, but something like vim isn't? Something about how they're compiled? They look the same to me:

$ file $(which vim)
/usr/bin/vim: PE32+ executable (console) x86-64 (stripped to external PDB), for MS Windows
$ file $(which hx)
/c/Users/rrc/.cargo/bin/hx: PE32+ executable (console) x86-64, for MS Windows
pascalkuthe commented 1 year ago

helix targets x86-64-pc-windows by default for windows (at least if you use the release artifacts). Many unix programs are either compiled using mysys or MinGW directly and likely behave differently as a result. By default windows doesn't really have unix-like signal handling.

You could try building for x86-64-pc-windows-mingw instead

rcorre commented 1 year ago

That sounds like it might be the trick, but I'm struggling to compile for windows-gnu: https://github.com/helix-editor/helix/discussions/6907

rcorre commented 1 year ago

I managed to compile in a MSYS2 mingw-x64 environment, and unfortunately I get the same message: 0 [sig] bash 4333! sigpacket::process: Suppressing signal 17 to win32 process (pid 7240)