Skip to content

Cursor position is set with wrong values after finish running a git command in integrated console #1639

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
daxian-dbw opened this issue Dec 4, 2021 · 3 comments · Fixed by #1732
Assignees
Milestone

Comments

@daxian-dbw
Copy link
Member

Summary

Cursor position contains the wrong values after the prompt comes back from running a git command, such as git push, git log, and git branch. But it's fine after running git status. See the screen GIF below.

Please be noted that, the color of *regex in the prompt is different after running git push, git log and git branch, but the color is correct after running git status. When the color of *regex becomes different, you will observe the misplacing of cursor when typing.

Animation

However, things are working fine within the default pwsh in the same VSCode terminal (not the integrated console). See the GIF below.
The default pwsh is the same version as the integrated console 7.2.0, and uses the same version of PSReadLine.

Animation2

Investigation

I tried to find what's happening within PSReadLine under a debugger, and I found that, when PSConsoleReadLine.ReadLine gets called after finish running git log -1 or git push, cosnole.CursorLeft == 19, even though the cursor-left looks to be at 7 based on what's shown on the terminal. It looks the terminal state somehow gets corrupted after running git push, git log, or git branch.

Environment

PSES Extension Version

PS:5> $host  

Name             : Visual Studio Code Host
Version          : 2021.11.1
InstanceId       : 3c0bc9b5-f6b2-45be-96c8-44ed2d1c767f
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : en-US
CurrentUICulture : en-US
PrivateData      : 
DebuggerEnabled  : True
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace

PSReadLine version

PS:15> gmo PSReadLine

ModuleType Version    PreRelease Name
---------- -------    ---------- ----
Script     2.2.0      beta4      PSReadLine
@ghost ghost added the Needs: Triage Maintainer attention needed! label Dec 4, 2021
@SeeminglyScience
Copy link
Collaborator

Probably need to implement PSHost.Notify*Application to reset the console mode (or just call ConsoleHost.Notify*Application which already does that).

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Dec 5, 2021
@andyleejordan andyleejordan added Issue-Bug A bug to squash. and removed Needs: Triage Maintainer attention needed! Needs: Maintainer Attention Maintainer attention needed! labels Dec 17, 2021
@andyleejordan andyleejordan self-assigned this Dec 17, 2021
@andyleejordan andyleejordan added this to the Committed milestone Dec 17, 2021
@andyleejordan
Copy link
Member

Took a brief look at your linked PR @daxian-dbw. Is this something we'll still need to address in PSES after that PR presumably fixes it? We have a big "TODO" in PSES Internal Host to "do something" in PSHost.Notify*Application:

public override void NotifyBeginApplication()
{
// TODO: Work out what to do here
}
public override void NotifyEndApplication()
{
// TODO: Work out what to do here
}

@daxian-dbw
Copy link
Member Author

We still need to address it in PSES because PSHost.Notify*Application is host specific, and in case of PSES, it does nothing today. I can give this a stab, but may not be able to get to it very soon.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Dec 17, 2021
@StevenBucher98 StevenBucher98 removed the Needs: Maintainer Attention Maintainer attention needed! label Jan 5, 2022
@andyleejordan andyleejordan moved this to Todo in Sea Biscuit Jan 20, 2022
SeeminglyScience added a commit to SeeminglyScience/PowerShellEditorServices that referenced this issue Feb 28, 2022
@andyleejordan andyleejordan moved this from Todo to In Progress in Sea Biscuit Feb 28, 2022
Repository owner moved this from In Progress to Done in Sea Biscuit Feb 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants