Skip to content

Restore down then maximizing the Windows Terminal causes PSReadline to misplace the cursor #1456

@zadjii-msft

Description

@zadjii-msft

Environment

From conhost:

PS version: 7.0.0
PSReadline version: 2.0.0
os: 10.0.19601.1000 (WinBuild.160101.0800)
PS file version: 7.0.0.0
HostName: ConsoleHost
BufferWidth: 248
BufferHeight: 68

Additionally, from WT:

PS version: 7.0.0
PSReadline version: 2.0.0
os: 10.0.19601.1000 (WinBuild.160101.0800)
PS file version: 7.0.0.0
HostName: ConsoleHost (Windows Terminal)
BufferWidth: 120
BufferHeight: 30

Steps to reproduce

See microsoft/terminal#2432 and microsoft/terminal#5254

Windows Terminal Repro

  1. Open Terminal in full screen
  2. Type ls
  3. unmaximize the window
  4. maximize the window
  5. type ls again and see that ls is not positioned correctly

displaybug

Conhost repro

With a plain old conhost:

  • Maximize it
  • Run ls
  • Restore down
  • Change the buffer size to match the window size
  • Maximize again

Expected behavior

Text appears at previous cursor line

Actual behavior

Text appears in blank space. Screenshots of process:

pane-text-1

pane-text-2

pane-text-3

Notes

I'm moving this here because I'm having a hard time tracing through this from our side, and I figured it'd be easier to get help straight from the experts. From my own investigation

This issue: PowerShell/PSReadLine#682
and the associated PR: PowerShell/PSReadLine#694

Which pointed me to this function
PowerShell/PSReadLine:PSReadLine/Render.cs@198a643#L985-L1000

I can't be sure that's actually it, but that's certainly something to look into.

Though, reading through that, it looks like _console.CursorTop might already be wrong at that point in the call. Looks like that function is just trying to see how many rows the input line takes, then is setting the _initialY to be that many rows above the cursor. So I'd think the cursor was already wrong at this point.

I'll keep digging

Metadata

Metadata

Assignees

Labels

Issue-BugIt either shouldn't be doing this or needs an investigation.Resolution-Fixed

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions