catchorg / Catch2

A modern, C++-native, test framework for unit-tests, TDD and BDD - using C++14, C++17 and later (C++11 support is in v2.x branch, and C++03 on the Catch1.x branch)
https://discord.gg/4CWS9zD
Boost Software License 1.0
18.51k stars 3.04k forks source link

Handle ANSI escape sequences during text wrapping #2833

Closed jeremy-rifkin closed 4 months ago

jeremy-rifkin commented 6 months ago

Description

I'd like to provide diagnostic messages from a Catch::Matchers::MatcherBase::describe function that are colored with ANSI sequences, however Catch2's line wrapping interferes with this.

Would a PR to update the line wrapping logic be welcomed?

Additional context

I have an assertion library that I'd like to provide a catch2 integration for. Without color codes, with my current attempt to make it work in Catch2, it looks like this:

image

However with color codes the lines are messed up and escape sequences are split in the middle:

image