Skip to content

Fix readline backspace/line-wrapping on linux#2969

Merged
AndreasBackx merged 1 commit into
pallets:mainfrom
yorickvP:main
Apr 29, 2026
Merged

Fix readline backspace/line-wrapping on linux#2969
AndreasBackx merged 1 commit into
pallets:mainfrom
yorickvP:main

Conversation

@yorickvP
Copy link
Copy Markdown
Contributor

@yorickvP yorickvP commented Jun 7, 2025

termui contains a workaround for windows where it prints a readline prompt itself. On linux, this confuses readline so things like backspace/ctrl-backspace and line wrapping don't work correctly.

On platforms other than windows, just let readline handle the prompt.

fixes #2968

Note: while I used claude code to offload some manual work creating this PR, I've steered and reviewed all the changes and take personal responsibility for the contents.

@yorickvP
Copy link
Copy Markdown
Contributor Author

Rebased out the conflicting version bumps and fixed the stdout/stderr situation.

@jan-swiecki
Copy link
Copy Markdown

jan-swiecki commented Dec 9, 2025

I confirm that it resolves prompt backspace problems in llm (simonw/llm#356)

@kdeldycke kdeldycke changed the base branch from main to stable April 16, 2026 09:33
@kdeldycke kdeldycke added bug f:prompt feature: prompt for input labels Apr 22, 2026
@kdeldycke kdeldycke added this to the 8.4.0 milestone Apr 22, 2026
@kdeldycke
Copy link
Copy Markdown
Collaborator

kdeldycke commented Apr 22, 2026

I confirm this issue and the patch, which has been hinted at in #3021 and #3019. I noticed there the coupling of both prompt() / confirm() but could not make sense of their behavior. Until I saw this PR. This is the right fix but need to also apply to confirm(). I will amend this PR to fix both.

@kdeldycke
Copy link
Copy Markdown
Collaborator

kdeldycke commented Apr 22, 2026

@yorickvP : I just generalized your fix into a new _readline_prompt helper so both prompt() and confirm() benefits from it. Also squashed all the commit and rebased it on top of stable. Added some tests to confirm that <stdout> is no longer polluted.

Comment thread CHANGES.rst Outdated
@Rowlando13 Rowlando13 changed the base branch from stable to main April 29, 2026 07:05
Apply fix to prompt() and confirm(), which were covered in pallets#1836, pallets#2093 and pallets#3019

Co-authored-by: Kevin Deldycke <kevin@deldycke.com>
@AndreasBackx AndreasBackx merged commit 2468b70 into pallets:main Apr 29, 2026
12 checks passed
@AndreasBackx
Copy link
Copy Markdown
Collaborator

Thanks again @yorickvP for these fixes. Also thank you @kdeldycke for the small cleanup and rebase.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators May 14, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bug f:prompt feature: prompt for input

Projects

None yet

Development

Successfully merging this pull request may close these issues.

backspace and line-wrapping acting strange on Linux

6 participants