Skip to content

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

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

Open
encukou opened this issue Jan 23, 2025 · 1 comment
Open
Labels
topic-repl Related to the interactive shell type-bug An unexpected behavior, bug, or error

Comments

@encukou
Copy link
Member

encukou commented Jan 23, 2025

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

@encukou encukou added OS-windows topic-repl Related to the interactive shell type-bug An unexpected behavior, bug, or error labels Jan 23, 2025
@StanFromIreland
Copy link
Contributor

StanFromIreland commented Feb 26, 2025

This also causes weird behavior on Linux for example this happened:

Image

Image

If I move my cursor up on a small screen it results in:

Image

This occurred several times when trying it.

Ptyixs on Fedora 41, cpython main branch

@encukou encukou changed the title REPL on Windows doesn't handle blocks larger than the console window REPL doesn't handle blocks larger than the console window on some terminals Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-repl Related to the interactive shell type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants