Skip to content

Keep the cursor visible at wrapped input boundaries - #2174

Open
yuxino wants to merge 1 commit into
prompt-toolkit:mainfrom
yuxino:fix/wrapped-cursor-scroll
Open

yuxino wants to merge 1 commit into
prompt-toolkit:mainfrom
yuxino:fix/wrapped-cursor-scroll

Conversation

@yuxino

@yuxino yuxino commented Nov 12, 2026

Copy link
Copy Markdown

When a one-row TextArea with wrap_lines=True fills its width exactly, the cursor can jump to the terminal's top-left corner. For example, with a 20-column input and a >>> prompt, typing abcdefghijklmnop triggers it. Typing another character restores the cursor, and moving left back to the boundary triggers it again.

Include the character under the cursor when calculating the scroll height. The height helper's slicing behavior and prefix-width guards stay intact.

Refs #2071 and follows up on the exact-boundary case in #2084, whose author invited others to take it over. I reproduced this boundary jump, but not the accumulating horizontal drift in #2071.

Verified with real macOS PTY input and VT100 output, plus regression tests for prompts, continuation prefixes, wide characters, and one- and two-row windows. The full test suite and configured checks pass on Python 3.14. Hermes, Linux/SSH and WSL were not tested.

Prepared with AI assistance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant