You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Console corruption on Unix PTYs when completion wraps near bottom row (stale _initialY drift) #5217
N/A (no crash or exception thrown; visual/screen corruption occurs).
Steps to reproduce
In a terminal with standard dimensions (e.g. 24 rows, 80 columns), run several commands (e.g. 1..15 | ForEach-Object { "line $_" }) so that output fills the screen and the prompt sits at or near the bottom row.
Type a command with long paths or multiple completion candidates (e.g. Get-ChildItem /data/data/com.termux/files/usr/ or deep directories).
Press Tab to cycle completions so that completion candidates expand across multiple physical lines and wrap past the bottom row.
Continue pressing Tab to cycle through candidates of varying lengths (wrapping and unwrapping).
Expected behavior
When completions wrap across multiple lines at the bottom of the screen, the terminal should scroll naturally and continue drawing downward into new lines without overwriting prior console history.
Actual behavior
As Tab cycles between candidates of different lengths:
Writing past the bottom row forces the terminal emulator to physically scroll lines upward.
Redrawing the prompt and candidate appears to calculate against the pre-scroll prompt anchor (_initialY), emitting absolute ANSI cursor coordinates (\e[row;colH) that land above the actual prompt position.
The prompt and new input progressively walk up the screen, drawing directly on top of earlier command outputs and history.
The screen remains corrupted until cleared with Clear-Host / cls.
Root cause analysis / Technical notes
On Unix-like platforms (.NET Core PTY), Console.BufferHeight equals Console.WindowHeight. When a multi-line input forces the terminal to scroll lines upward:
Physical lines shift up into the terminal emulator's scrollback buffer.
In Render.cs, redraws position the cursor using absolute coordinates via SetCursorPosition(_initialX, _initialY).
When subsequent renders are shorter (or when cycling between long and short completion candidates), positioning to _initialY places the cursor over earlier content that shifted into that row slot.
Unix shells (GNU Readline, ZLE, Fish) avoid this by navigating relatively (\e[A, \e[B, \r) rather than using absolute row addressing.
Activity