Skip to content
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

3-line commands that scrolled the window in powershell visually duplicate if partially deleted #13071

Closed
omgitsraven opened this issue May 9, 2022 · 5 comments
Labels
Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Tag-Fix Doesn't match tag requirements Resolution-External For issues that are outside this codebase

Comments

@omgitsraven
Copy link

Windows Terminal version

1.12.10982.0

Windows build number

10.0.19044.0

Other Software

No response

Steps to reproduce

  1. Open Windows Terminal
  2. Open a Powershell terminal
  3. Press the enter key repeatedly, until the content of the window begins to scroll (so that the active prompt is at the bottom of the window.)
  4. Type a command that wraps onto three lines, but do not hit enter. (The command doesn't have to be valid, you can just hold down the q key.)
  5. Start deleting characters with the backspace key, until the command should fit onto two lines. (Go slightly past it fitting exactly; make some empty space on the end of the second line.)

Expected Behavior

You should see a two-line-long command after your prompt.

Actual Behavior

Once you delete enough characters to fit exactly on two lines, the window scrolls up for some reason... And then, once you delete one character MORE than that, the first two lines visually mash up to create a command that appears to still be three lines long! (The command actually still runs normally, it's just very confusing to edit...)

Here is an example, where I filled the first line with as, the second line with bs, and the third line with cs, and then deleted the third line and some of the second:

Before deleting anything:
image

After pressing backspace several times:
image

Also, note that this happens in Powershell running inside Windows Terminal, but NOT when attempted in the standalone Powershell prompt.

@omgitsraven omgitsraven added the Issue-Bug It either shouldn't be doing this or needs an investigation. label May 9, 2022
@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels May 9, 2022
@j4james
Copy link
Collaborator

j4james commented May 12, 2022

I don't know what the problem is here, but I did briefly look into it, and I just wanted to note some of the things I discovered.

  1. When the PowerShell prompt wraps at the bottom of the viewport, it's just calling SetConsoleCursorPosition to position the cursor below the viewport bottom, and that triggers a SetViewportOrigin call which pans the viewport down. As far as I can tell, that viewport movement doesn't propagate over conpty as a scroll event, so you lose any lines that scroll off the top.
  2. When the prompt has wrapped over 3 lines, and you backspace to the start of that third line, PowerShell generates a linefeed for some reason. That forces the viewport to pan down an additional row leaving an extra blank line. You can see that in conhost too - it's not just a conpty thing. As weird as that is, though, it shouldn't be causing anything to break, but I thought it might be the trigger for whatever is subsequently going wrong.

It's also worth noting that point 1 is possibly the same bug we're seeing in #10905.

@zadjii-msft
Copy link
Member

Oh, that does sound familiar, yea. @omgitsraven I wonder if an updated PsReadline might just fix this for you/?

@ghost ghost added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label May 16, 2022
@omgitsraven
Copy link
Author

Updating PSReadLine to 2.2.5 has fixed it!! Thank you :)

Does that mean I should close this issue then, if that fix will work its way to everyone eventually?

@ghost ghost added Needs-Attention The core contributors need to come back around and look at this ASAP. and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels May 16, 2022
@zadjii-msft
Copy link
Member

Yea, we can close this out as /dup PowerShell/PSReadLine#724

@zadjii-msft zadjii-msft closed this as not planned Won't fix, can't repro, duplicate, stale May 16, 2022
@ghost
Copy link

ghost commented May 16, 2022

Hi! We've identified this issue as a duplicate of one that exists on somebody else's Issue Tracker. Please make sure you subscribe to the referenced external issue for future updates. Thanks for your report!

@ghost ghost added Resolution-External For issues that are outside this codebase and removed Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Attention The core contributors need to come back around and look at this ASAP. labels May 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Tag-Fix Doesn't match tag requirements Resolution-External For issues that are outside this codebase
Projects
None yet
Development

No branches or pull requests

3 participants