Skip to content

Wrap multiline prompt text above the input - #2164

Open
charan-rathore wants to merge 1 commit into
prompt-toolkit:mainfrom
charan-rathore:fix-multiline-prompt-wrap
Open

charan-rathore wants to merge 1 commit into
prompt-toolkit:mainfrom
charan-rathore:fix-multiline-prompt-wrap

Conversation

@charan-rathore

Copy link
Copy Markdown

Problem

A prompt with a newline puts the text above the input in a separate window. That window does not inherit wrap_lines, so long prompt lines are cut off even when wrapping is enabled.

Change

Use the session's wrap_lines filter for the prompt window above the input as well. The filter stays dynamic, and wrap_lines=False still clips the line.

The regression tests render a PromptSession in a narrow terminal. They cover a long prompt line, several long lines, short lines, an exact-width line wrapping disabled and changing a wrap filter between prompts.

Fixes #2010.

Tests

  • New regressions against unmodified main: 3 failed, 5 passed.
  • With the fix: 8 passed in tests/test_shortcuts.py.
  • Full suite: 162 passed.
  • ruff check . and ruff format --check .: passed.
  • mypy --strict src/ for Linux, Windows and macOS: passed.
  • typos .: passed.

These checks ran locally on Linux with Python 3.14.10. A separate VT100 output capture also shows the long prompt wrapping instead of being cut off.

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.

Newline characters in a prompt disable line wrap

1 participant