Win10 1809 调用 CMD/PowerShell/Bash 显示错乱问题

最近升级到了 Windows 10 1809 版本,发现在 VSCode, Android Studio, PhpStorm 终端窗口中的 CMD/PowerShell/Bash 都有显示错乱的现象,终端在最初打开时光标不能正常显示,只有在执行命令后光标才会出现。

@domske

Just another recorded gif to show the issue. (recorded before I searched for duplicates. 😄 )

screen

I wondering, is this “really” a bug of Windows 10 - 1809? … Anyway we should handle this. Maybe by replacing all line breaks at initializing the terminal? Or just emulate the enter key to reprint the prompt? The second solution is more a workaround and a bit dirty. But should work. …

winpty/issues/156#issuecomment-462546424

@Tyriar, got the same issue. Same OS background. Using RS5 Insider Builds

The whole terminal experience in VSCode on Windows Insiders is pretty rough right now. Output Buffers overwriting and regular terminal inputs like CTRL+Backspace printing command characters… issues like that have been increasingly visible to me since RS5.

vscode/issues/57803#issuecomment-419664569

@jpalo

Same here on 17763.1 with VS Code 1.27.2, but has been several earlier Windows Insider builds. I usually just press enter once to see the command prompt in terminal, or lately I’ve just ignored the fact that there is no prompt and just type in the command, as it works nicely.

vscode/issues/57803#issuecomment-423547233

Same goes for zeit/Hyper. After the active dev windows insider ring was lifted onto 19H1, i can also report that the issue persists with the 19H1 prerelease, too.

I have this issue too on my Windows 10 Pro 1809, Build 17764.1, when opening a new terminal window.

Actually it depends on the size resp. height of the terminal window, whether or how the issue shows up:

  • Terminal window maximized: no issue with new terminals
  • Terminal height below around 22 lines: no cursor, when typing jumps to top with a number of spaces before it
  • Teminal height below around 12 lines: no text and no cursor at all (cursor shortly flashes before disappearing)

After pressing ENTER everything is ok.

Guys, this may not be related to VS at all. I’m also a user of Android Studio and when I open the terminal tab in the lower panel I get the same issue.

vscode/issues #57803: Terminal not in a good state initially on Windows Insider builds

rprichard/winpty #156: Reducing window height on startup breaks cmd/powershell as of recent 1809 builds

rprichard/winpty #152: Use Microsoft’s new ConPTY API on Windows versions which support it (i.e. Fall 2018 and newer)

Microsoft/vscode #67903: [Windows 10][Insider build] Conpty cannot be enabled in Feb.4 Insider build

Microsoft/console #270: Investigate apparent WinPTY issue with RS5/19H1 builds

Microsoft/console #255: SetConsoleWindowInfo + cmd/powershell yields invisible prompt

大佬们是这样说的

@rprichard (Owner of the winpty repository)

I can reproduce it, but I don’t know what’s going wrong yet. When I debug it by setting the WINPTY_SHOW_CONSOLE=1 environment variable, I see the same sort of broken output in the console window that I see in the terminal window. If there’s a HKCU\Console entry for the path to the winpty-agent.exe binary, then the problem doesn’t reproduce. Somehow the lack of that entry, combined with winpty’s startup code, is leaving the console in a bad state when the cmd/powershell process starts.

FWIW: I’m thinking of having winpty itself use conpty when it can: rprichard/winpty#152. I’m happy with node-pty using conpty directly, though.

@rprichard

If there’s a HKCU\Console entry for the path to the winpty-agent.exe binary, then the problem doesn’t reproduce.

winpty uses SetConsoleWindowInfo during startup, and if that call reduces the height of the console window, then starting cmd/powershell later breaks. I have a non-winpty test case that I’ll attach to a console bug report. (It sounds like it’s too late to fix in Windows, though.)

I also opened rprichard/winpty#156 to track the problem.

@Tyriar (Member of the Microsoft organization)

Upstream issue: Microsoft/console#270

For people experiencing this issue, the way I work around it in the meantime is to just press enter which shows the prompt. You can also just type a command and it will run fine, it’s just that the initial prompt doesn’t display correctly.

@Tyriar

ConPTY support is landing in the next Insiders build, this uses a new backend for the terminal on WIndows 10 build number 17692+, this is expected to fix many bugs in the terminal on Windows as we’re adopting Microsoft’s official pty API. For earlier versions winpty will still be used a many bugs will still remain (unless they’re fixed in that project).

译:

对 ConPTY 的支持会在下一个 Insiders Build 中发布,它会被用于在 Windows 10 内部版本号 17692+ 上作为终端的新后端,预计这将修复终端在 Windows 下的许多错误,我们正在适配微软官方的 pty API。对于早期版本,winpty 仍然会被使用,但会留下许多错误(除非它们已在该项目中修复)。

vscode/issues/57803#issuecomment-449495423

@Tyriar

Update: Windows build number 18309+ is now required for ConPTY to be turned on as it was not stable on 17692.

译:
(VSCode 中) 需要 Windows 内部版本号 18309+ 才能开启使用 ConPTY,因为在 17692 上 ConPTY 不稳定。

vscode/issues/45693#issuecomment-456937675

hhh 最后将锅甩给了 Winpty

Windows terminal issues caused by winpty #45693

Winpty

Windows 更新导致 Winpty 发生了奇怪的问题

有许多软件目前使用的是 Winpty 做为终端的后端(例如 VSCode, PhpStorm, bash.exe)

Q: Winpty 是什么?

A: winpty 是一个 Windows 软件包,提供了类似 Unix pty-master 一样的接口,用于实现控制台程序之间的通讯。该软件包包括一个开发库 (libwinpty) 和一个用于 ygwin 和 MSYS 的工具用于在 Cygwin/MSYS pty 下运行 Windows 控制台程序。

rprichard/winpty #156: Reducing window height on startup breaks cmd/powershell as of recent 1809 builds

rprichard/winpty #152: Use Microsoft’s new ConPTY API on Windows versions which support it (i.e. Fall 2018 and newer)

@rprichard

I’m thinking of having winpty itself use conpty when it can: rprichard/winpty#152. I’m happy with node-pty using conpty directly, though.

ConPTY

Windows 命令行:Windows 伪控制台(ConPTY)的介绍

GitHub 仓库

The new Win32 ConPTY API (formal docs to follow soon) is now available in recent Windows 10 Insider builds and corresponding Windows 10 Insider Preview SDK, and will ship in the next major release of Windows 10 (due sometime in fall/winter 2018).

译:

新的 Win32 ConPTY API(即将推出的正式文档)现在可以在最近的 Windows 10 Insider 版本和相应的 Windows 10 Insider Preview SDK中使用,并将在 Windows 10 的下一个 major release(2018年秋/冬的某个时间)发布。

This will use the ConPTY system provided by the Windows Console team as the backend for the terminal. Enabling this should fix many issues with the Windows terminal, particularly around color support, interactive applications, and shells that natively support VT sequences.

Windows 10 1809 (内部版本号 17763.316) 已加入 ConPTY

VSCode 在 January 2019 (version 1.31) 的更新中已添加对 ConPTY 的支持,见 更新日志

VSCode 目前在同时使用 Winpty(供旧版系统使用) 和 ConPTY,但需要 Windows 内部版本号 18309+ 才能开启使用 ConPTY,因为在 17692 上 ConPTY 并不稳定。

18309+ 可以设置直接勾选使用 ConPTY:

1
"terminal.integrated.windowsEnableConpty": ture

1809 版本目前就是个坑,WinPTY 有问题,ConPTY 不稳定… 可以加入 “预览体验计划” 升级 Windows 到 18309+ 来解决,或者忍,或是等……

嗯,就这样…

日后,各种软件可以用 ConPTY 代替 WinPty,或等待 WinPty 的更新…

总之,1089 版本目前就是个坑… 等待 Windows 新的正式版发布……

伪终端 (Pseudoterminal) 真有意思,有时间以后慢慢补…..

本站文章除注明转载外均为原创,未经允许不要转载哇. ヾ(゚ー゚ヾ) http://qwqaq.com/527f8ae.html
分享到