Handle non-printable characters in diff view (#11687)

Co-authored-by: Micha Reiser <micha@reiser.io>
This commit is contained in:
aditya pillai 2024-06-07 23:22:03 -07:00 committed by GitHub
parent ee1621b2f9
commit ed947792cf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 82 additions and 59 deletions

View file

@ -10,6 +10,7 @@ use ruff_diagnostics::{Applicability, Fix};
use ruff_source_file::{OneIndexed, SourceFile};
use crate::message::Message;
use crate::text_helpers::ShowNonprinting;
/// Renders a diff that shows the code fixes.
///
@ -101,6 +102,7 @@ impl Display for Diff<'_> {
)?;
for (emphasized, value) in change.iter_strings_lossy() {
let value = value.show_nonprinting();
if emphasized {
write!(f, "{}", line_style.apply_to(&value).underline().on_black())?;
} else {