-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
git bash for windows in terminal does not break lines correctly #9359
Comments
Forgot to mention I saw this on preview. I have not checked on the "official" version yet. I have added the version number to the post above. |
I also see this in the official version
|
Well that's super weird. I don't think that's necessarily caused by the same thing that's causing the If that happens again, can you use task manager to capture a dump file of Terminal when that dialog pops up? |
I see this behavior with every FYI: |
Does |
Regarding the error message:
As described in STATUS_STACK_BUFFER_OVERRUN doesn’t mean that there was a stack buffer overrun, the same exception code is nowadays used for other purposes too. I don't know whether Windows nowadays bothers to check the fast-fail code before it pops up the message box with this wording. |
To add what we know from the other issue #10152, can you check your TERM environment variable when you experience the formatting issue or even the crash? In my situation, it depends on what value it has. Apparently, Git Bash defaults to Terminal definitely behaves different here from other console emulators like the default conhost, mintty or ConEmu. |
In my case in Windows Terminal Preview v1.11.2421.0: $ echo $TERM
xterm-256color When I run "Git Bash" from the Start Menu (which uses mintty): $ echo $TERM
xterm |
Both are |
How about the On Linux, Git would output just a LF, the Linux tty driver would convert that to CR LF, and the terminal would move the cursor to the start of the line on CR and then to the next line on LF. This behaviour of the terminal driver can be enabled or disabled with the ONLCR flag in the tcsetattr function, or with the On Windows, the console host does not convert LF to CR LF, so I assume this is instead done by some emulation layer in the Git for Windows package. If the emulated ONLCR flag has become turned off (e.g. because an editor such as |
FYI, on Windows this behaviour is controlled by the |
I was mislead by MicrosoftDocs/Console-Docs#132. Anyway, if I run |
Correct; vim takes an output console from git with ENABLE_PROCESSED_OUTPUT | ENABLE_WRAP_AT_EOL_OUTPUT adds DISABLE_NEWLINE_AUTO_RETURN | ENABLE_VIRTUAL_TERMINAL_PROCESSING and returns it dirty (even if it doesn't crash AFAIK). adding functionality in Git for Windows that resets the terminal after vi returns workarounds the issue and will be present in a future release |
Obviously a hack, as this needs to be done properly in compat/terminal but as a workaround to issue microsoft/terminal#9359 that is caused by some misbehaving vim (msys, included with Git for Windows) Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
When EDITOR is invoked to modify a commit message, it will likely change the console settings, and if it misbehaves, will leave the console output as shown in microsoft/terminal#9359. Use the recently added {push,pop}_term() functions to save the terminal state and recover safely, instead. [1] microsoft/terminal#9359 Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
When EDITOR is invoked to modify a commit message, it will likely change the console settings, and if it misbehaves, will leave the console output as shown in microsoft/terminal#9359. Use the recently added {push,pop}_term() functions to save the terminal state and recover safely, instead. [1] microsoft/terminal#9359 Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
When EDITOR is invoked to modify a commit message, it will likely change the terminal settings, and if it misbehaves will leave the terminal output as shown in microsoft/terminal#9359. Instead use the recently added {push,pop}_term() functions to save the terminal configuration and recover safely. [1] microsoft/terminal#9359 Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
When EDITOR is invoked to modify a commit message, it will likely change the terminal settings, and if it misbehaves will leave the terminal output as shown in microsoft/terminal#9359. Instead use the recently added {push,pop}_term() functions to save the terminal configuration and recover safely. [1] microsoft/terminal#9359 Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
When EDITOR is invoked to modify a commit message, it will likely change the terminal settings, and if it misbehaves will leave the terminal output damaged as shown in a recent report from Windows Terminal[1] Instead use the functions provided by compat/terminal to save the settings and recover safely. [1] microsoft/terminal#9359 Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
FWIW the workaround from git to reset the terminal settings after vi is invoked has been merged and is released as part of the last Git for Windows prerelease: https://github.com/git-for-windows/git/releases/tag/v2.34.0-rc0.windows.1 This should avoid the most egregious cases until a final solution to keep them consistent is found |
Git now works around [an issue with `vi` and incorrect line breaks in the Windows Terminal](microsoft/terminal#9359). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
When EDITOR is invoked to modify a commit message, it will likely change the terminal settings, and if it misbehaves will leave the terminal output damaged as shown in recent reports from Windows Terminal[1] Instead use the functions provided by compat/terminal to save the settings of the terminal and recover safely, but only do so if instructed by the user through a new configuration "editor.rogue" and the terminal is fully interactive. [1] microsoft/terminal#9359 Helped-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
When EDITOR is invoked to modify a commit message, it will likely change the terminal settings, and if it misbehaves will leave the terminal output damaged as shown in recent reports from Windows Terminal[1] Instead use the functions provided by compat/terminal to save the settings of the terminal and recover safely, but only do so if instructed by the user through a new configuration "editor.rogue" and the terminal is fully interactive. [1] microsoft/terminal#9359 Helped-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Proactively activate the rogue.editor configuration option if the user persists on using VIM even after being warned against it, to avoid the possibility of terminal output corruption like the one described in microsoft/terminal#9359. Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Proactively activate the rogue.editor configuration option if the user persists on using VIM even after being warned against it, to avoid the possibility of terminal output corruption like the one described in microsoft/terminal#9359. Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Proactively activate the rogue.editor configuration option if the user persists on using VIM even after being warned against it, to avoid the possibility of terminal output corruption like the one described in microsoft/terminal#9359. Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
Proactively activate the rogue.editor configuration option if the user persists on using VIM even after being warned against it, to avoid the possibility of terminal output corruption like the one described in microsoft/terminal#9359. Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
FYI, I made a fatal mistake on the way this workaround was implemented originally within git and therefore the code had to be reverted for 2.34.1, but luckily the Git for Windows maintainer picked it up and might still work when using 2.34.1.windows.1 (or later). If you are having problems, make sure to NOT have any of the environment variables used to override the editor defined in your environment (ex: VISUAL, EDITOR, GIT_EDITOR, GIT_SEQUENCE_EDITOR) AND NOT have a core.editor setting, OR that they are set exactly to 'vi' or 'vim' ('vim.exe' or '/usr/bin/vi' will not activate the workaround and still corrupt your terminal). |
When EDITOR is invoked to modify a commit message, it will likely change the terminal settings, and if it misbehaves will leave the terminal output damaged as shown in recent reports from Windows Terminal[1] Instead use the functions provided by compat/terminal to save the settings of the terminal and recover safely, but only do so if instructed by the user through a new configuration "editor.rogue" and the terminal is fully interactive. [1] microsoft/terminal#9359 Helped-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
When EDITOR is invoked to modify a commit message (or do some other editing), and it is a terminal mode editor, it will need to change the terminal settings, and if it misbehaves could leave the terminal output damaged as shown in recent reports from Windows Terminal[1] Instead use the functions provided by compat/terminal to save the settings of the terminal and recover safely, but only do so if the editor is known to have issues and unless the user has told us through a boolean configuration "editor.stty" that it is safe not to do so. [1] microsoft/terminal#9359 Signed-off-by: Junio C Hamano <gitster@pobox.com>
I am experiencing something similar with WSL 2.0 and Ubuntu in the Windows Terminal, with git version 2.25.1 - yet that shouldn't be git for windows; but just plain old git: It happens after having run an interactive rebase (which I assume is also when vim is opened.). I've set the editor to vim, (as per @carenas suggestion) rather than the full vim-path, yet it didn't do anything better or worse. Is this related to the problem? and do you brilliant people know of any quick fix? |
the mentioned workaround only applies to git for windows (requires code in git that is not part of the regular codebase yet). it definitely looks like the same problem, and as documented in #10152 another workaround that doesn't require code changes is to set TERM to something else than xterm*; ex:
it is important also to note that running |
I never tested vt100, @carenas - i did now. vt100 didn't do much more than removing my beautiful colors. Reset is currently my preferred trick. but might just postfix the |
will see if I can try again to get my fix merged into git upstream (hopefully for 2.37), which then could be maybe backported to your version; but considering your version is old and probably out of maintenance it might be worth upgrading it regardless. |
@carenas You know if this was ever fixed upstream? Or, if it wasn't, is there an upstream issue we could point this thread at? |
AFAIK the "fix" implemented in git for windows[1] is only a workaround to the effects of this bug. |
I'm experiencing a similar situation where Git Bash for Windows messed up line wrapping (and consequently doesn't break lines properly). To replicate:
See this image to illustrate: I should add that changing the EDIT: Nevermind, found my issue and it isn't caused by Windows Terminal... I had a function in my .bashrc that was overriding the $PS1 variable incorrectly. Fixed it and confirm everything is working. This issue was plaguing me for about a year now... But no longer. |
Hi all! There's been a lot of changes in this space recently, and we're hoping it gets better with 1.18 which is slated to come out in a few months. |
FWIW, in my case what triggers the issue is this line...
...that I added at some point to my .bashrc file. IOW, I've just discovered that if I comment that line and relaunch the terminal I get the expected output: Whereas as soon I uncomment it and relaunch the terminal, I start getting this again: Curious thing is for some reason the behavior only changes after the second interaction once activated/deactivated the culprit line (no matter if I relaunch or reload), as can be seen in the first capture. Well, I hope it somehow helps, or give some clue at least, on figuring out what could be going on cause it's certainly annoying... and what if (as happen to be the case) you need such or other similar settings to be active? 🙄 Cheers. git version 2.45.1.windows.1 |
If toggling an msys feature on and off changes the behaviour of msys, it may be worth filing a bug on msys! I'm not sure how that would impact Terminal, but it is a really great data point. Thanks! FWIW: it looks like that terminal is mintty, so we might not even be involved here (since msys applications use a special connection they have with mintty to skip all the Windows Console code) |
Environment
Setting for git bash:
Steps to reproduce
Expected behavior
Line breaks start at the beginning of the next line.
Actual behavior
git rod
is an alias forgit rebase --autostash -i origin/develop
It seems that only the console without
\r
is not returning the operator to the beginnig of the line.Not sure if there is a setting I need to configure for this to work.
The text was updated successfully, but these errors were encountered: