Visual Studio Code + zsh + ConPTY = input issues #541

Open
opened 2026-01-30 21:54:44 +00:00 by claunia · 17 comments
Owner

Originally created by @Xjs on GitHub (Jan 28, 2019).

I was sent here via https://github.com/Microsoft/vscode/issues/67227

  • Your Windows build number:
    Microsoft Windows [Version 10.0.18323.1000]

  • What you're doing and what's happening: (Copy & paste specific commands and their output, or include screen shots)
    I type in the VS Code integrated terminal. Always at the second letter after the prompt, the cursor seems to jump momentarily. Sometimes single characters of my input aren't processed, but I couldn't reproduce this when trying to take a video. However, it is definitely related to the jumping/flickering.

Looks like this:

flicker

NB: I can only reproduce this issue with zsh (version 5.4.2 (x86_64-pc-msys)), not with PowerShell nor bash.

@Tyriar pointed me at the terminal.integrated.windowsEnableConpty option. With that option disabled, the problem is gone.

  • What's wrong / what should be happening instead:

The cursor shouldn't flicker/jump, all input should be processed, the same way as when ConPTY is disabled. Like this:

noflicker

Originally created by @Xjs on GitHub (Jan 28, 2019). I was sent here via https://github.com/Microsoft/vscode/issues/67227 * Your Windows build number: Microsoft Windows [Version 10.0.18323.1000] * What you're doing and what's happening: (Copy & paste specific commands and their output, or include screen shots) I type in the VS Code integrated terminal. Always at the second letter after the prompt, the cursor seems to jump momentarily. Sometimes single characters of my input aren't processed, but I couldn't reproduce this when trying to take a video. However, it is definitely related to the jumping/flickering. Looks like this: ![flicker](https://user-images.githubusercontent.com/58270/51853431-93fce800-2328-11e9-9991-08a23e70de85.gif) NB: I can only reproduce this issue with zsh (version 5.4.2 (x86_64-pc-msys)), not with PowerShell nor bash. @Tyriar pointed me at the `terminal.integrated.windowsEnableConpty` option. With that option disabled, the problem is gone. * What's wrong / what should be happening instead: The cursor shouldn't flicker/jump, all input should be processed, the same way as when ConPTY is disabled. Like this: ![noflicker](https://user-images.githubusercontent.com/58270/51853440-98290580-2328-11e9-8f46-76300770fb42.gif)
Author
Owner

@zadjii-msft commented on GitHub (Jan 28, 2019):

This is going to sound insane, but does this repro if you launch a normal console window, then launch WSL, then from WSL launch cmd.exe, then within the interop'd cmd launch WSL again, so your process tree looks something like this:

wsl.exe
└── cmd.exe
│   └── wsl
│   │   └── zsh

Launching cmd.exe from within wsl is a good way to be able to activate conpty from within the context of a normal console window. Hopefully that can help me figure out if this is due to differences handling the conpty output or if it's inherent to what output we're emitting.

edit: filed MSFT:20331700 to make sure this gets investigated

@zadjii-msft commented on GitHub (Jan 28, 2019): This is going to sound insane, but does this repro if you launch a normal console window, then launch WSL, then from WSL launch cmd.exe, then within the interop'd cmd launch WSL again, so your process tree looks something like this: ``` wsl.exe └── cmd.exe │ └── wsl │ │ └── zsh ``` Launching cmd.exe from within wsl is a good way to be able to activate conpty from within the context of a normal console window. Hopefully that can help me figure out if this is due to differences handling the conpty output or if it's inherent to what output we're emitting. edit: filed MSFT:20331700 to make sure this gets investigated
Author
Owner

@Xjs commented on GitHub (Jan 28, 2019):

@zadjii-msft Thanks for your reply. I'll try that tomorrow. However, my zsh inside VS code is compiled against MinGW (so it runs natively, not in WSL). I guess I'll leave the second wsl.exe step out then?

@Xjs commented on GitHub (Jan 28, 2019): @zadjii-msft Thanks for your reply. I'll try that tomorrow. However, my zsh inside VS code is compiled against MinGW (so it runs natively, not in WSL). I guess I'll leave the second wsl.exe step out then?
Author
Owner

@zadjii-msft commented on GitHub (Jan 28, 2019):

Oh, yea do that. If zsh.exe is in your %path%, you could probably also leave out the cmd.exe.

@zadjii-msft commented on GitHub (Jan 28, 2019): Oh, yea do that. If zsh.exe is in your %path%, you could probably also leave out the cmd.exe.
Author
Owner

@Xjs commented on GitHub (Jan 29, 2019):

Doesn't reproduce in the described WSL setting.

Not sure if I did everything correctly. Here's what I did:

  • Launch WSL
  • Execute cmd.exe from WSL (starts a cmd.exe shell inside the WSL window)
  • Execute zsh.exe from that cmd shell.

Also tried:

  • Launch WSL
  • Execute /mnt/c/.../zsh.exe directly

The input glitch seems not to occur in these settings.

@Xjs commented on GitHub (Jan 29, 2019): Doesn't reproduce in the described WSL setting. Not sure if I did everything correctly. Here's what I did: * Launch WSL * Execute cmd.exe from WSL (starts a cmd.exe shell inside the WSL window) * Execute zsh.exe from that cmd shell. Also tried: * Launch WSL * Execute /mnt/c/.../zsh.exe directly The input glitch seems not to occur in these settings.
Author
Owner

@zadjii-msft commented on GitHub (Jan 29, 2019):

That's kinda what I expected tbh. VsCode/xterm.js is probably a little faster at rendering the results of a VT sequence than conhost is, so you can see a bit more of how conpty constructs the frame in the middle of a frame.

I'm certain that conpty isn't remotely emitting optimal sequences, so my current theory is that some optimizations might be able to remedy this behavior.

@zadjii-msft commented on GitHub (Jan 29, 2019): That's kinda what I expected tbh. VsCode/xterm.js is probably a little faster at rendering the results of a VT sequence than conhost is, so you can see a bit more of how conpty constructs the frame in the middle of a frame. I'm _certain_ that conpty isn't remotely emitting optimal sequences, so my current theory is that some optimizations might be able to remedy this behavior.
Author
Owner

@zadjii-msft commented on GitHub (Jan 29, 2019):

So, good and bad news. Bad news is that I can't get this to repro on my build of VsCode+Conpty.

However, there was a bug very recently that caused some crazy terrible conpty perf that should be out in Insiders just about now. The fix is coming soon, probably in the next Insiders build. If I had to guess, without drilling in deeper, that bug fix might also alleviate this problem.

I'll leave this open though. If it's not gone in the next Insider's Build, then I'll try and drill in some more and narrow it down.

@zadjii-msft commented on GitHub (Jan 29, 2019): So, good and bad news. Bad news is that I can't get this to repro on my build of VsCode+Conpty. However, there was a bug very recently that caused some crazy terrible conpty perf that should be out in Insiders just about now. The fix is coming soon, probably in the next Insiders build. If I had to guess, without drilling in deeper, that bug fix might also alleviate this problem. I'll leave this open though. If it's not gone in the next Insider's Build, then I'll try and drill in some more and narrow it down.
Author
Owner

@Xjs commented on GitHub (Jan 31, 2019):

@zadjii-msft Still occurs. -- NB: It must have something to do with zsh.

I can reproduce a missing keystroke now, too: Delete a word backwards with Alt-Backspace, the next pressed key will not be typed.

@Xjs commented on GitHub (Jan 31, 2019): @zadjii-msft Still occurs. -- NB: It must have something to do with zsh. I can reproduce a missing keystroke now, too: Delete a word backwards with Alt-Backspace, the next pressed key will not be typed.
Author
Owner

@DHowett-MSFT commented on GitHub (Jan 31, 2019):

@Xjs The insider's build with the performance fix hasn't gone out yet. It'll go out in the next build whose build number is >= 18330.

@DHowett-MSFT commented on GitHub (Jan 31, 2019): @Xjs The insider's build with the performance fix hasn't gone out yet. It'll go out in the next build whose build number is >= 18330.
Author
Owner

@Xjs commented on GitHub (Feb 1, 2019):

@DHowett-MSFT @zadjii-msft Ah, sorry, are we talking about a Windows Insiders build or a VS Code insiders build? (I had assumed the latter, but Build 18330 seems to imply the former)

@Xjs commented on GitHub (Feb 1, 2019): @DHowett-MSFT @zadjii-msft Ah, sorry, are we talking about a Windows Insiders build or a VS Code insiders build? (I had assumed the latter, but Build 18330 seems to imply the former)
Author
Owner

@zadjii-msft commented on GitHub (Feb 1, 2019):

@Xjs Yes, I was referring to a Windows Insider's build - conpty fixes and enhancements need to ship with the OS.

@zadjii-msft commented on GitHub (Feb 1, 2019): @Xjs Yes, I was referring to a Windows Insider's build - conpty fixes and enhancements need to ship with the OS.
Author
Owner

@Xjs commented on GitHub (Feb 11, 2019):

I'm on build 18334.1 now, the issue persists.

@Xjs commented on GitHub (Feb 11, 2019): I'm on build 18334.1 now, the issue persists.
Author
Owner

@DHowett-MSFT commented on GitHub (May 14, 2019):

To quote @zadjii-msft:

Punting this one - I can't get it to repro on 19H1_release_dep.190126.

If I had to guess, this was related to the really bad perf issue from a few weeks back, where the frame would repaint on every color change.

@DHowett-MSFT commented on GitHub (May 14, 2019): To quote @zadjii-msft: > Punting this one - I can't get it to repro on 19H1_release_dep.190126. > > If I had to guess, this was related to the really bad perf issue from a few weeks back, where the frame would repaint on every color change.
Author
Owner

@wight554 commented on GitHub (Apr 19, 2021):

Is there any progress for this one?
Winpty is broken on latest vscode insiders (can't input anything)
So I don't have other choice now

@wight554 commented on GitHub (Apr 19, 2021): Is there any progress for this one? Winpty is broken on latest vscode insiders (can't input anything) So I don't have other choice now
Author
Owner

@zadjii-msft commented on GitHub (Apr 20, 2021):

Is there any progress for this one?

Nope, we couldn't get this to repro locally, so we didn't know how to even begin investigating. What build of Windows are you on? (& specific VSCode build number would be useful as well).

@zadjii-msft commented on GitHub (Apr 20, 2021): > Is there any progress for this one? Nope, we couldn't get this to repro locally, so we didn't know how to even begin investigating. What build of Windows are you on? (& specific VSCode build number would be useful as well).
Author
Owner

@wight554 commented on GitHub (Apr 20, 2021):

Is there any progress for this one?

Nope, we couldn't get this to repro locally, so we didn't know how to even begin investigating. What build of Windows are you on? (& specific VSCode build number would be useful as well).

Windows 19042.867
Terminal 1.7.1033.0
VSCode 1.56.0-insider/1.55.2
Msys2 + zsh package + VSCode "terminal.integrated.shell.windows" set to zsh
No WSL in my case

@wight554 commented on GitHub (Apr 20, 2021): > > Is there any progress for this one? > > Nope, we couldn't get this to repro locally, so we didn't know how to even begin investigating. What build of Windows are you on? (& specific VSCode build number would be useful as well). Windows 19042.867 Terminal 1.7.1033.0 VSCode 1.56.0-insider/1.55.2 Msys2 + zsh package + VSCode "terminal.integrated.shell.windows" set to zsh No WSL in my case
Author
Owner

@wight554 commented on GitHub (Apr 20, 2021):

Other than this I've got xonsh crashes (issue linked higher) with VS Code + ConPTY
It works fine in windows terminal

@wight554 commented on GitHub (Apr 20, 2021): Other than this I've got xonsh crashes (issue linked higher) with VS Code + ConPTY It works fine in windows terminal
Author
Owner

@0x1ee7 commented on GitHub (Sep 2, 2021):

I have to run wsl under powershell to effectively run zsh in a useful manner. Otherwise zle is just messing up the input buffer and the command executed becomes different than the one presented. Input line becomes garbled, prompt is overwriten in some cases or parts of input is concatenated to the prompt in others. Mostly happen after moving the cursor left/right by arrow keys or moving it by words bindkey ";5D" backward-word & bindkey ";5C" forward-word etc. (conpty/winpty does not really matter)

// workaround in settings.json
    "terminal.integrated.profiles.linux": {
        "zsh": {
            "path": "pwsh.exe",
            "args": [
                "-c",
                "wsl"
            ],
            "icon": "terminal-debian",
        }
    },
    "terminal.integrated.defaultProfile.linux": "zsh",
@0x1ee7 commented on GitHub (Sep 2, 2021): I have to run wsl under powershell to effectively run zsh in a useful manner. Otherwise `zle` is just messing up the input buffer and the command executed becomes different than the one presented. Input line becomes garbled, prompt is overwriten in some cases or parts of input is concatenated to the prompt in others. Mostly happen after moving the cursor left/right by arrow keys or moving it by words `bindkey ";5D" backward-word` & `bindkey ";5C" forward-word` etc. (conpty/winpty does not really matter) ```json // workaround in settings.json "terminal.integrated.profiles.linux": { "zsh": { "path": "pwsh.exe", "args": [ "-c", "wsl" ], "icon": "terminal-debian", } }, "terminal.integrated.defaultProfile.linux": "zsh", ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#541