Skip to content

fix: use character as insert_text for character-valued ANSI_SEQUENCES entries - #2089

Open
dajiaohuang wants to merge 1 commit into
prompt-toolkit:mainfrom
dajiaohuang:fix-character-valued-ansi-sequence
Open

fix: use character as insert_text for character-valued ANSI_SEQUENCES entries#2089
dajiaohuang wants to merge 1 commit into
prompt-toolkit:mainfrom
dajiaohuang:fix-character-valued-ansi-sequence

Conversation

@dajiaohuang

Copy link
Copy Markdown

Description

When a character-valued entry is added to ANSI_SEQUENCES (e.g., for xterm modifyOtherKeys support), the KeyPress data should be the character, not the raw escape sequence. Otherwise, self-insert bindings will insert the escape sequence instead of the character.

Fixes

Fixes #2086

Changes

  • src/prompt_toolkit/input/vt100_parser.py: In _call_handler, when key is a plain character (not a Keys member), use the character as insert_text instead of the raw escape sequence
  • tests/test_inputstream.py: Add regression test test_character_valued_ansi_sequence

Behavior Change

Before: ANSI_SEQUENCES["\x1b[27;2;78~"] = "N" would cause KeyPress("N", "\x1b[27;2;78~") to be created, and self-insert would insert the raw escape sequence
After: KeyPress("N", "N") is created, and self-insert correctly inserts "N"

… entries

When a character-valued entry is added to ANSI_SEQUENCES (e.g., for
xterm modifyOtherKeys support), the KeyPress data should be the character,
not the raw escape sequence. Otherwise, self-insert bindings will insert
the escape sequence instead of the character.

Fixes prompt-toolkit#2086
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.

Character-valued ANSI_SEQUENCES entries insert their escape sequence instead of the character

1 participant