microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
160.03k stars 28.03k forks source link

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

Open Phroneris opened 1 week ago

Phroneris commented 1 week ago

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:

VS Code version: Code 1.90.1 (611f9bfce64f25108829dd295f54a6894e87339d, 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 commented 1 week ago

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: 611f9bfce64f25108829dd295f54a6894e87339d 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 commented 1 week ago

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: 611f9bfce64f25108829dd295f54a6894e87339d 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 commented 1 week ago

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

Version: 1.90.1 (user setup) Commit: 611f9bfce64f25108829dd295f54a6894e87339d 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 commented 1 week ago

@Hayabusa58 @shlomi-borovitz-greenroad for oh-my-posh see https://github.com/microsoft/vscode/issues/211922

shlomi-borovitz-greenroad commented 6 days ago

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

Fixed for me

Hayabusa58 commented 3 days ago

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

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

mcdurdin commented 2 days ago

@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.