terminal: git bash for windows in terminal does not break lines correctly

Environment

Platform ServicePack Version      VersionString
-------- ----------- -------      -------------
 Win32NT             10.0.18363.0 Microsoft Windows NT 10.0.18363.0

Windows Terminal Preview
Version: 1.7.572.0

Setting for git bash:

            {
                "name": "git bash",
                "commandline": "%PROGRAMFILES%/git/usr/bin/bash.exe -i -l",
                "icon": "%PROGRAMFILES%/Git/mingw64/share/git/git-for-windows.ico",
                "startingDirectory" : "%USERPROFILE%"
            },

Steps to reproduce

  1. Open a terminal window with git for windows bash
  2. Do a rebase operation

Expected behavior

Line breaks start at the beginning of the next line.

Actual behavior

git rod is an alias for git rebase --autostash -i origin/develop

$git rod
error: could not apply 6b04f92e... DuplicateInput now supports generating code for arrays for the VfcTypeImplementation
                                                                                                                                  Resolve all conflicts manually, mark them as resolved with
                                                                                                                                                                                            "git add/rm <conflicted_files>", then run "git rebase --continue".
                                                                                                                                                                                                                                                              You can instead skip this commit: run "git rebase --skip".
                                           To abort and get back to the state before "git rebase", run "git rebase --abort".
                                                                                                                            Recorded preimage for 'src/App/Changelog.md'
                                                                                                                                                                        Could not apply 6b04f92e... DuplicateInput now supports generating code for arrays for the VfcTypeImplementation
                      Auto-merging src/App/Tests/Silt.Plugin.SimpleTransformersGeneratorTests/GeneratorTests/DuplicateInputTransformerTests.cs
                                                                                                                                              Auto-merging src/App/Plugins/Silt.Plugin.SimpleTransformersGenerator/GeneratorStrategy/DuplicateInputTransformer.cs
                                                                                                                                                                                                                                                                 Auto-merging src/App/Changelog.md
                     CONFLICT (content): Merge conflict in src/App/Changelog.md

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.

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 7
  • Comments: 26 (4 by maintainers)

Commits related to this issue

Most upvoted comments

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

So maybe someone is setting that mode and not restoring it on exit.

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

I never tested vt100, @carenas - i did now.

image

vt100 didn’t do much more than removing my beautiful colors. Reset is currently my preferred trick. but might just postfix the reset command to my alias.

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:

> export TERM=vt100

it is important also to note that running reset after vi is invoked should also fix the terminal, as well as fixing your rbim command/alias so it doesn’t attempt to run vi in a non terminal, if that is possible (expect might help there)

FYI, on Windows this behaviour is controlled by the DISABLE_NEWLINE_AUTO_RETURN output mode. So maybe someone is setting that mode and not restoring it on exit. If that’s the problem, it could potentially be fixed by #4954.