Repository navigation
Fix character-valued ANSI_SEQUENCES entries inserting their escape sequence - #2179
Open
draarivpatel-ui wants to merge 1 commit into
Open
draarivpatel-ui wants to merge 1 commit into
draarivpatel-ui wants to merge 1 commit into
Conversation
…quence When an entry in ANSI_SEQUENCES maps to a plain character rather than a Keys member, the key press carried the raw escape sequence as data, so the sequence itself was typed into the buffer instead of the character. Fixes prompt-toolkit#2086
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2086.
ANSI_SEQUENCESmay map an escape sequence to a plain single character rather than aKeysmember (for example, what a terminal in xtermmodifyOtherKeys=2mode sends forShift+N). Such an entry resolved to the correct key, but the resultingKeyPresscarried the raw escape sequence as its data payload, so the sequence itself was typed into the buffer:The parser now substitutes the character itself as the data payload for plain-character mappings. Escape sequences mapping to
Keysmembers are unchanged, and so are tuple-valued entries (used for meta/alt key combinations), where only the first key press carries the payload.Verified end to end through a real
PromptSessionusing the reproduction from the issue: input"ab" + "\x1b[27;2;78~" + "cd\r"now yieldsabNcdinstead of embedding the raw escape sequence. Regression test added intests/test_inputstream.py; the full test suite passes (157 passed), andruff check,ruff format --checkandmypyare clean on the changed files.