Skip to content

terminal restart for integrated pwsh can cause cursor to go to wrong location #304257

Closed

Description

@amunger

I had a terminal restart occur for some reason, and from there, the cursor went to the wrong location and was not working well.
Resizing/minimizing the window did not help.
had "terminal.integrated.windowsUseConptyDll": true,
running clear made the issue go away.

Image

Activity

  1. amunger commented on Mar 23, 2026

    @amunger
    CollaboratorAuthor

    related to #241978

  2. Tyriar commented on Mar 25, 2026

    @Tyriar
    Contributor

    Probably need to do:

    // Conpty v1.22+ uses passthrough and doesn't reprint the buffer often, this means that when
    // the terminal is revived, the cursor would be at the bottom of the buffer then when
    // PSReadLine requests `GetConsoleCursorInfo` it will be handled by conpty itself by design.
    // This causes the cursor to move to the top into the replayed terminal contents. To avoid
    // this, the post restore message will print new lines to get a clear viewport and put the
    // cursor back at to top left.
    let postRestoreMessage = '';
    if (isWindows) {
    const lastReplayEvent = terminal.replayEvent.events.length > 0 ? terminal.replayEvent.events.at(-1) : undefined;
    if (lastReplayEvent) {
    postRestoreMessage += '\r\n'.repeat(lastReplayEvent.rows - 1) + `\x1b[H`;
    }
    }

    Here too:

    // For normal terminals write a message indicating what happened and relaunch
    // using the previous shellLaunchConfig
    const message = localize('ptyHostRelaunch', "Restarting the terminal because the connection to the shell process was lost...");
    this._onProcessData.fire({ data: formatMessageForTerminal(message, { loudFormatting: true }), trackCommit: false });
    await this.relaunch(this._shellLaunchConfig, this._dimensions.cols, this._dimensions.rows, false);

  3. added
    bug
    terminal-conpty
    important
    on Mar 30, 2026
  4. vs-code-engineering commented on Apr 1, 2026

    @vs-code-engineering
    Contributor

    Sharing media from merged PR #307212 for verification:

    ptyRestartFix.mp4

    Source PR: #307212

  5. added
    unreleased
    insiders-released
    and removed
    unreleased
    on Apr 1, 2026
  6. locked and limited conversation to collaborators on May 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugimportantinsiders-releasedterminal-conptyverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions