Skip to content
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

Long prompt text with shell integration causes "ghost" text display in the VSCode bash terminal #215617

Open
Phroneris opened this issue Jun 15, 2024 · 7 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug terminal-shell-bash An issue in the terminal specific to bash terminal-shell-integration Shell integration, command decorations, etc.
Milestone

Comments

@Phroneris
Copy link

Phroneris commented Jun 15, 2024

Type: Bug

When $PS1 is enough long, and when shell integration is enabled, the bash terminal in VSCode sometimes gets weird text before each prompt.

Example:

$ PS1='\n\[\e[32m\]Short prompt text, OK.\[\e[0m\]\n$ '

Short prompt text, OK.
$ 

Short prompt text, OK.
$ echo $PS1
\[\]\n\[\e[32m\]Short prompt text, OK.\[\e[0m\]\n$ \[\]

Short prompt text, OK.
$ PS1='\n\[\e[36m\]A bit longer prompt text, OK. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.\[\e[0m\]\n$ '

A bit longer prompt text, OK. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
$ 

A bit longer prompt text, OK. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
$ echo $PS1
\[\]\n\[\e[36m\]A bit longer prompt text, OK. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.\[\e[0m\]\n$ \[\]

A bit longer prompt text, OK. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
$ PS1='\n\[\e[35m\]Very long prompt text, bad! Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\[\e[0m\]\n$ '
por incididunt ut labore et dolore magna aliqua.\\[\\e[0m\\]\\n$ ';43490313-b88b-4f99-af78-d356ca0b3e38
Very long prompt text, bad! Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
$ 
empor incididunt ut labore et dolore magna aliqua.\x1b[0m\x0d\x0a$ 
Very long prompt text, bad! Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
$ echo $PS1
\[\]\n\[\e[35m\]Very long prompt text, bad! Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\[\e[0m\]\n$ \[\]
empor incididunt ut labore et dolore magna aliqua.\x1b[0m\x0d\x0a$ 
                                                                   Very long prompt text, bad! Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
 eiusmod tempor incididunt ut labore et dolore magna aliqua.
$

But you would prefer screenshot:

vscode-ghost-in-the-shell

The reason I call them ghosts is because they can be purified by vertical resizing of the terminal:

vscode-ghost-in-the-shell

Notes:

  • This issue occurs even when all extensions are disabled.
  • This issue doesn't occur when shell integration is disabled or in standalone Git Bash (by Git for Windows).
  • My actual $PS1 when encountered this issue is \[\033]0;$TITLEPREFIX:$PWD\007\]\n\[\033[32m\]\u@\h \[\033[35m\]$MSYSTEM \[\033[33m\]\w\[\033[36m\]`__git_ps1 " (%s) \[\033[1;34m\]$(gitGetUserConfigs)"`\[\033[0m\]\n$ . This generates prompt such as user@host MINGW64 /c/path/to/my/supercalifragilisticexpialidocious/repo (main =) Phroneris <[email protected]> [local] and it sometimes gets enough long to cause this issue.
  • I was initially going to report this on Git for Windows because this happened to me just after updating it from v2.24.0 to v2.45.2, but then I tried many things and found that this occurs only in the VSCode terminal with shell integration enabled, so here I am.
  • Not sure of the relevance, but I notice that echoed $PS1 always has additional \[\] to both ends; this addition occurs only in the VSCode terminal with shell integration enabled.
  • Region/Language: Japan/Japanese

VS Code version: Code 1.90.1 (611f9bf, 2024-06-11T21:01:24.262Z)
OS version: Windows_NT x64 10.0.19045
Modes:

System Info
Item Value
CPUs Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz (4 x 3193)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: unavailable_off
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) undefined
Memory (System) 31.89GB (23.51GB free)
Process Argv --crash-reporter-id 0d0f4325-8fb8-4df0-af46-0539e77eed8e
Screen Reader no
VM 0%
Extensions: none
A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805cf:30301675
binariesv615:30325510
vsaa593:30376534
py29gd2263:31024239
c4g48928:30535728
azure-dev_surveyone:30548225
a9j8j154:30646983
962ge761:30959799
pythongtdpath:30769146
pythonidxpt:30866567
pythonnoceb:30805159
asynctok:30898717
pythontestfixt:30902429
pythonregdiag2:30936856
pythonmypyd1:30879173
h48ei257:31000450
pythontbext0:30879054
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
jchc7451:31067544
dsvsc021:30996838
g316j359:31013175
pythoncenvpt:31062603
a69g1124:31058053
dvdeprecation:31068756
pythonprt:31056678
dwnewjupytercf:31046870

@mcdurdin
Copy link

Yes, seeing similar, I see this occurring with Git Bash 2.45.0, and only happening within VSCode:

mcdurdin@THARK MINGW64 /c/Projects/keyman/app/developer (fix/developer/11643-prevent-non-bmp-chars-in-key-part-of-rule)
$

mcdurdin@THARK MINGW64 /c/Projects/keyman/app/developer (fix/developer/11643-prevent-non-bmp-chars-in-key-part-of-rule)
$ cd src/kmcmplib
1b[0m\x0d\x0a$ 
mcdurdin@THARK MINGW64 /c/Projects/keyman/app/developer/src/kmcmplib (fix/developer/11643-prevent-non-bmp-chars-in-key-part-of-rule)
$
1b[0m\x0d\x0a$ 
mcdurdin@THARK MINGW64 /c/Projects/keyman/app/developer/src/kmcmplib (fix/developer/11643-prevent-non-bmp-chars-in-key-part-of-rule)
$ cd ..

mcdurdin@THARK MINGW64 /c/Projects/keyman/app/developer/src (fix/developer/11643-prevent-non-bmp-chars-in-key-part-of-rule)
$

mcdurdin@THARK MINGW64 /c/Projects/keyman/app/developer/src (fix/developer/11643-prevent-non-bmp-chars-in-key-part-of-rule)
$

image

image

$ echo $PS1
\[\]\[\033]0;$TITLEPREFIX:$PWD\007\]\n\[\033[32m\]\u@\h \[\033[35m\]$MSYSTEM \[\033[33m\]\w\[\033[36m\]`__git_ps1`\[\033[0m\]\n$ \[\]

Version: 1.90.1 (user setup)
Commit: 611f9bf
Date: 2024-06-11T21:01:24.262Z
Electron: 29.4.0
ElectronBuildId: 9593362
Chromium: 122.0.6261.156
Node.js: 20.9.0
V8: 12.2.281.27-electron.0
OS: Windows_NT x64 10.0.19045

@shlomi-borovitz-greenroad

I think it is related, as it has similar effects and symptoms

I'm using oh-my -posh with "rpromt" (text that appears after the prompt)

It works in windows terminal, as well if I turn off shell integrations:
image

But with shell integration the whole rprompt is messed up
image

Version: 1.90.1 (user setup)
Commit: 611f9bf
Date: 2024-06-11T21:01:24.262Z (5 days ago)
Electron: 29.4.0
ElectronBuildId: 9593362
Chromium: 122.0.6261.156
Node.js: 20.9.0
V8: 12.2.281.27-electron.0
OS: Windows_NT x64 10.0.22631

@Hayabusa58
Copy link

I have same problem. I also using oh-my-posh
image

Version: 1.90.1 (user setup)
Commit: 611f9bf
Date: 2024-06-11T21:01:24.262Z
Electron: 29.4.0
ElectronBuildId: 9593362
Chromium: 122.0.6261.156
Node.js: 20.9.0
V8: 12.2.281.27-electron.0
OS: Windows_NT x64 10.0.19045

@Tyriar
Copy link
Member

Tyriar commented Jun 17, 2024

@Hayabusa58 @shlomi-borovitz-greenroad for oh-my-posh see #211922

@Tyriar Tyriar added this to the June 2024 milestone Jun 17, 2024
@Tyriar Tyriar added bug Issue identified by VS Code Team member as probable bug terminal-shell-integration Shell integration, command decorations, etc. terminal-shell-bash An issue in the terminal specific to bash labels Jun 17, 2024
@shlomi-borovitz-greenroad

@Hayabusa58 @shlomi-borovitz-greenroad for oh-my-posh see #211922

Fixed for me

@Hayabusa58
Copy link

@Hayabusa58 @shlomi-borovitz-greenroad for oh-my-posh see #211922

Updated VSCode to v1.90.2, and I got fixed. Thanks!

@mcdurdin
Copy link

@Hayabusa58 @shlomi-borovitz-greenroad for oh-my-posh see #211922

Updated VSCode to v1.90.2, and I got fixed. Thanks!

v1.90.2 does not fix the issue in Bash terminals.

@Tyriar Tyriar modified the milestones: June 2024, July 2024 Jun 26, 2024
@Tyriar Tyriar modified the milestones: July 2024, On Deck Jul 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug terminal-shell-bash An issue in the terminal specific to bash terminal-shell-integration Shell integration, command decorations, etc.
Projects
None yet
Development

No branches or pull requests

6 participants