Skip to content

Escape a C1 CSI in ANSI.format - #2114

Open
SashaMIT wants to merge 1 commit into
prompt-toolkit:mainfrom
SashaMIT:ansi-c1-escape
Open

SashaMIT wants to merge 1 commit into
prompt-toolkit:mainfrom
SashaMIT:ansi-c1-escape

Conversation

@SashaMIT

@SashaMIT SashaMIT commented Oct 1, 2026 •

Copy link
Copy Markdown

Summary

ANSI("x{}").format("\x9b31mRED") returned RED in ansired. % did the same. \x1b[31mRED was already a question mark. \x9b is the C1 form of ESC [, and ansi_escape only replaced \x1b and backspace.

The argument is now ?31mRED with no color. ANSI("\x9b32mOK") in the template is still green.

Fixes #2113

Test plan

  • test_ansi_c1_interpolation fails on tip and passes with the extra replace
  • test_ansi_interpolation and test_ansi_formatting still pass

\x9b is the C1 form of ESC [, and an argument could set a color.
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.

ANSI.format lets a C1 CSI set a color

1 participant