Repository navigation
Description
Windows Terminal version (or Windows build number)
1.7.1033.0
Other Software
Using Git for Windows version 2.31.1.windows.1 with the bundled vim v8.2.1895 with PowerShell 5.1.19041.906.
Steps to reproduce
In a new folder, enter the following commands after another:
PS C:\TerminalIssueRepro> $env:TERM = 'msys'
PS C:\TerminalIssueRepro> git init
PS C:\TerminalIssueRepro> 'bin/' > .gitignore
PS C:\TerminalIssueRepro> git add .\.gitignore
PS C:\TerminalIssueRepro> git commit
vim opens to prompt for a commit message, so enter something there, save and exit.
Expected Behavior
The console window should look like this:
PS C:\TerminalIssueRepro> git init
Initialized empty Git repository in C:/TerminalIssueRepro/.git/
PS C:\TerminalIssueRepro> 'bin/' > .gitignore
PS C:\TerminalIssueRepro> git add .\.gitignore
PS C:\TerminalIssueRepro> git commit
[main (root-commit) abe2cba] Initialize
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 .gitignore
PS C:\TerminalIssueRepro>
Actual Behavior
Instead, due to the TERM=msys, the output looks like this:
PS C:\TerminalIssueRepro> git init
Initialized empty Git repository in C:/TerminalIssueRepro/.git/
PS C:\TerminalIssueRepro> 'bin/' > .gitignore
PS C:\TerminalIssueRepro> git add .\.gitignore
PS C:\TerminalIssueRepro> git commit
[main (root-commit) abe2cba] Initialize
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 .gitignore
This can be reproduced by re-triggering vim for editing, e.g. using git commit --amend. Sometimes, the terminal process completely crashes after closing vim, e.g. with this output:
PS C:\TerminalIssueRepro> git commit --amend
[main 27a142f] Initialize
Date: Sat May 22 14:20:41 2021 +0200
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 .gitignore
[Verarbeitung des Prozesses mit Code 5 beendet]
(Eror message says “Processing of process ended with code 5”)
If I switch to the TERM mode cygwin (the default I believe?), then the output will look ok in that there is no odd indentation and the process won’t crash. However doing so means that after exiting vim, the screen will be completely blank above the generated output, i.e. the vim process blanks the previous console output.
In ConEmu, using TERM=msys works without any problems, so does it in the native PowerShell host or cmd.exe.
Activity
DHowett commentedon May 27, 2021
This is fascinating.
/feedback
poke commentedon May 28, 2021
I unfortunately cannot use the Feedback hub on this machine since my domain policies prevent me from changing the data privacy settings that are required to use it… I can try to replicate this during the weekend on a different computer.
For what it’s worth, I couldn’t replicate the crash just now (of course not… 🙄) but here you have a screenshot of the funny output:
carenas commentedon Sep 6, 2021
interestingly; observing the odd formatting issue also but using the default TERM=xterm-color (or xterm) and a git bash tab, I also don't see the problem if using git bash directly (hence mintty) or the regular console (cmd or powershell)
TERM=cygwin workarounds the problem, and the issue can be seen in both the release and preview versions of Windows Terminal
UPDATE: built a custom git version to debug the formatting, and it would seem to be a residual misconfiguration of the terminal after vim closes, if using a different EDITOR for commit message the problem is not reproducible either regardless of TERM
zadjii-msft commentedon Sep 7, 2021
Wait so, after your update I'm not entirely clear what the state of this is. Did this go away with a updated git version? If not, then I'd be interested in the diff between the
infocmpforxterm-color,cygwin, andansi.WAIT is this
vim.exe, or avimthat ships with msys/cygwin?carenas commentedon Sep 7, 2021
no, but it could be handled there even if we don't have yet the facilities to do so.
git for windows doesn't have ansi on its terminfo, but xterm-256color and cygwin diff in:
https://pastebin.com/y4pwLZ1D
msys vim, which comes with git for windows and is invoked by default through a shell script in the emulated POSIX tree as /usr/bin/vi
you can reproduce it locally by installing git for windows[1] and running the git bash integration with windows terminal AS-IS.
[1] https://gitforwindows.org/
reece-bennett commentedon Sep 11, 2021
I'm not seeing any crashes but am experiencing the misaligned output.
I'm on git version 2.32.0.windows.2 and using vim as my editor (the default one that comes bundled with Git for Windows).
Everything looks fine in mintty that Git for Windows installs:
But in Windows Terminal I get the odd output (also happening for me in VSCode terminal):
zadjii-msft commentedon Sep 15, 2021
You know, we've got the same exact thing going on over in #9359, so I[m gonna close this as a dupe an put all the discussion in one place. Thanks! /dup #9359
carenas commentedon Oct 2, 2021
Yes and no; I coded a branch with the facility that was missing in git to be able to handle this terminal corruption, and I am able to solve the endemic problem that was reported here and in other related tickets.
vim is using an msys pty, while git is using a conio (hence conPTY when supported), but IMHO that configuration should work and it almost does (vi is able to change the terminal settings and control its screen and almost return it back clean); the only missing flag that is evident would seem to be "onlcr" and my code fixes that part by clearing that missing DISABLE_NEWLINE_AUTO_RETURN after vim exit.
BUT if I kill vim forcefully, there are a lot more flags that are not set correctly and EVEN if I am writing back the same conio flags from before vim was spawned, the terminal is still missing onlcr and shows the indented output, therefore still requiring a
reset.