长提示文本与Shell集成导致在VSCode bash终端中显示"ghost"文本,

uujelgoq  于 4个月前  发布在  Vscode
关注(0)|答案(7)|浏览(66)

类型:Bug
$PS1 足够长时,并且启用了 shell 集成,VSCode 中的 bash 终端有时会在每个提示符之前出现奇怪的文本。
示例:

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

但你更喜欢截图:

我称之为“幽灵”是因为它们可以通过调整终端的垂直大小来净化:

注意事项:

  • 即使禁用了所有扩展,此问题仍会发生。
  • 当禁用 shell 集成或使用独立的 Git Bash(由 Git for Windows)时,此问题不会发生。
  • 我实际遇到的 $PS1\[\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$ 。当我遇到这个问题时,它生成了类似于 user@host MINGW64 /c/path/to/my/supercalifragilisticexpialidocious/repo (main =) Phroneris <email@example.com> [local] 的提示符,有时长度足够长会导致此问题。
  • 我最初打算在 Git for Windows 上报告此问题,因为在我从 v2.24.0 更新到 v2.45.2 之后,它恰好发生在我身上,但后来我尝试了很多事情,发现只有在启用了 shell 集成的 VSCode 终端中才会出现此问题,所以我在这里报告。
  • 不确定相关性,但我注意到回显的 $PS1 总是在两端都有额外的 \[\] ;这种添加只发生在启用了 shell 集成的 VSCode 终端中。
  • 区域/语言:日本/日语

VS Code 版本:Code 1.90.1 ( 611f9bf ,2024-06-11T21:01:24.262Z)
操作系统版本:Windows_NT x64 10.0.19045
模式:
系统信息
| 项目 | 值 |
| ------ | ------ |
| CPUs | Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz (4 x 3193) |
| GPU状态 | 2d_canvas:enabledcanvas_oop_rasterization:enabled_ondirect_rendering_display_compositor:disabled_off_okgpu_compositing:enabledmultiple_raster_threads:enabled_onopengl:enabled_onrasterization:enabledraw_draw:disabled_off_okskia_graphite:disabled_offvideo_decode:enabledvideo_encode:unavailable_offvulkan:disabled_offwebgl:enabledwebgl2:enabledwebgpu:enabled |
| 平均负载 | undefined |
| 内存(系统) | 31.89GB (23.51GB free) |
| 进程参数 | --crash-reporter-id 0d0f4325-8fb8-4df0-af46-0539e77eed8e |
| 屏幕阅读器 | no |
| VM | 0% |扩展:无A/B实验

ncgqoxb0

ncgqoxb01#

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

lo8azlld

lo8azlld2#

是的,我看到了类似的情况,这发生在Git Bash 2.45.0中,仅在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)
$

$ 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$ \[\]

版本:1.90.1(用户设置)
提交:611f9bf
日期: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
操作系统:Windows_NT x64 10.0.19045

6ljaweal

6ljaweal3#

我认为它们是相关的,因为它们具有相似的效果和症状。
我正在使用oh-my-posh的"rprompt"(提示符后出现的文本)功能。
它在Windows终端中可以正常工作,如果我关闭了shell集成:

但是有了shell集成,整个rprompt就变得一团糟:

版本:1.90.1(用户设置)
提交:611f9bf
日期:2024-06-11T21:01:24.262Z(5天前)
Electron:29.4.0
ElectronBuildId:9593362
Chromium:122.0.6261.156
Node.js:20.9.0
V8:12.2.281.27-electron.0
操作系统:Windows_NT x64 10.0.22631

pdtvr36n

pdtvr36n4#

我也有同样的问题。我也在使用oh-my-posh。

版本:1.90.1(用户设置)
提交:611f9bf
日期: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
操作系统:Windows_NT x64 10.0.19045

eeq64g8w

eeq64g8w5#

@Hayabusa58 @shlomi-borovitz-greenroad 查看 oh-my-posh,代码为 #211922

kkbh8khc

kkbh8khc6#

@Hayabusa58@shlomi-borovitz-greenroad 用于 oh-my-posh 的代码片段已修复。

olhwl3o2

olhwl3o27#

@Hayabusa58@shlomi-borovitz-greenroad for oh-my-posh see #211922
Updated VSCode to v1.90.2, and I got fixed. Thanks!

相关问题