python / python/cpython

REPL doesn't handle blocks larger than the console window on some terminals

未關閉
#129,220 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

stdlib topic-repl type-bug
主要語言
Python
星號
77.2k
分支
36k
PR 合併指標
PR 指標待擷取

描述

Bug report

Bug description:

On Windows, if the currently edited block does not fit in the console (the lines are too long and there are too many lines), and the cursor is moved around, the REPL's state gets corrupted: lines are overwritten with parts of other lines, parts of the prompt appear in places, the cursor behaviour doesn't match the text around it.

For example, in a small console window, I pressed Up to go back in history to this piece of colorsys:

def yiq_to_rgb(y, i, q):
    # r = y + (0.27*q + 0.41*i) / (0.74*0.41 + 0.27*0.48)
    # b = y + (0.74*q - 0.48*i) / (0.74*0.41 + 0.27*0.48)
    # g = y - (0.30*(r-y) + 0.11*(b-y)) / 0.59

    r = y + 0.9468822170900693*i + 0.6235565819861433*q
    g = y - 0.27478764629897834*i - 0.6356910791873801*q
    b = y - 1.1085450346420322*i + 1.7090069284064666*q

    if r < 0.0:
        r = 0.0
    if g < 0.0:
        g = 0.0
    if b < 0.0:
        b = 0.0
    if r > 1.0:
        r = 1.0
    if g > 1.0:
        g = 1.0
    if b > 1.0:
        b = 1.0
    return (r, g, b)

and then pressed some arrow keys to get:

Image

CPython versions tested on:

CPython main branch

Operating systems tested on:

Windows

貢獻指南

開啟貢獻指南

從這裡開始

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

研究方向

首先,在一個對多行 colorsys 區塊來說過小的主控台視窗中重現 Windows 上的 REPL 編輯失敗,然後檢查 REPL 的歷史記錄和游標編輯進入點。執行報告中描述的方向鍵互動,並驗證當區塊超出視窗時,行、提示字元和游標位置仍保持對齊。

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

評估

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

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

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