Skip to content

fix: strip ANSI escape codes from error messages in output channel#4005

Open
sijie-Z wants to merge 1 commit into
prettier:mainfrom
sijie-Z:fix/strip-ansi-codes
Open

fix: strip ANSI escape codes from error messages in output channel#4005
sijie-Z wants to merge 1 commit into
prettier:mainfrom
sijie-Z:fix/strip-ansi-codes

Conversation

@sijie-Z

@sijie-Z sijie-Z commented Jun 2, 2026

Copy link
Copy Markdown

Problem

Since Prettier v12.x, error messages can contain ANSI color codes. The VS Code Output panel does not interpret ANSI
escape sequences, causing raw codes like [31m[1m to clutter the output and make errors unreadable.

Solution

Strip ANSI escape codes before writing messages to the output channel. Applied in LoggingService.logError() and
logMessage() so all log levels are covered.

Related Issue

Closes #4002

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature
  • Breaking change

Checklist

  • I have read the CONTRIBUTING guidelines
  • My code follows the code style of this project (npm run prettier passes)
  • I have run npm run prettier to format my code
  • I have added/updated tests
  • All new and existing tests pass
  • I have updated the CHANGELOG.md

Prettier v12.x started outputting ANSI color codes in error
messages. The VS Code Output panel does not interpret ANSI escape
sequences, causing raw codes like [31m[1m to clutter the output.

Strip ANSI codes before writing to the output channel so error
messages remain readable. Applied to LoggingService.logError()
and logMessage().

Closes prettier#4002
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.

Output channel displays raw ANSI escape codes for syntax errors in v12.x

1 participant