Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

Console corruption on Unix PTYs when completion wraps near bottom row (stale _initialY drift)

未關閉
#5,217 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
48/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
csharp
領域
cli

研究方向

Reproduce the completion wrapping scenario with an 80x24 Unix PTY, then read Render.cs and the redraw path around SetCursorPosition(_initialX, _initialY). Compare renders as candidates wrap, scroll, and shrink. Done means cycling completions no longer overwrites prior command history and the prompt remains correctly positioned after terminal scrolling.

由索引模型根據 Issue 內容生成。

描述

Needs-Triage :mag:

Environment

PS version: 7.4.19
PSReadline version: 2.3.6
os: Linux localhost 6.1.141-android14-11-o-gf61012bbfa24 #1 SMP PREEMPT Mon Aug 10 12:44:35 UTC 2026 aarch64 Android
PS file version: 7.4.19.0
HostName: ConsoleHost
BufferWidth: 80
BufferHeight: 24

Exception report

N/A (no crash or exception thrown; visual/screen corruption occurs).

Steps to reproduce

  1. 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.
  2. Type a command with long paths or multiple completion candidates (e.g. Get-ChildItem /data/data/com.termux/files/usr/ or deep directories).
  3. Press Tab to cycle completions so that completion candidates expand across multiple physical lines and wrap past the bottom row.
  4. 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:

  1. Physical lines shift up into the terminal emulator's scrollback buffer.
  2. In Render.cs, redraws position the cursor using absolute coordinates via SetCursorPosition(_initialX, _initialY).
  3. 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.
  4. Unix shells (GNU Readline, ZLE, Fish) avoid this by navigating relatively (\e[A, \e[B, \r) rather than using absolute row addressing.
主要語言
C#
星號
4.4k
分支
341
PR 合併指標
30 天內沒有已合併 PR

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

PowerShell/PSReadLine 的其他 Issue

查看 PowerShell/PSReadLine 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。