miette icon indicating copy to clipboard operation
miette copied to clipboard

Gracefully handle ANSI sequences inside of error messages

Open Veetaha opened this issue 1 year ago • 0 comments

If the error message contains some ANSI escape sequences, for example to make part of the message stand out. Then they get broken when the error message gets big and it wrapped onto the next line.

Here is an example, where the path to a file in the error message was highlighted in red bold.

image

But when part of the path was wrapped to the next line the styling broke (I expected the marker_rustc_driver to also be red and bold).

To overcome this issue miette could use style wrapping such that it preserves the ANSI sequences in the error messages and resets them to their values when it has to insert some characters inside of the error message (like the pipe character and an arrow to display the chain of errors).

See also yansi::Paint::wrap method that implements this logic

Veetaha avatar Aug 22 '23 20:08 Veetaha