Escape the delete character in filenames

This commit is contained in:
FliegendeWurst 2019-10-12 11:42:12 +02:00
parent 89c861f24d
commit b5b731071c
No known key found for this signature in database
GPG Key ID: CA38E82B54B32A88

View File

@ -2,7 +2,7 @@ use ansi_term::{ANSIString, Style};
pub fn escape<'a>(string: String, bits: &mut Vec<ANSIString<'a>>, good: Style, bad: Style) { pub fn escape<'a>(string: String, bits: &mut Vec<ANSIString<'a>>, good: Style, bad: Style) {
if string.chars().all(|c| c >= 0x20 as char) { if string.chars().all(|c| c >= 0x20 as char && c != 0x7f as char) {
bits.push(good.paint(string)); bits.push(good.paint(string));
} }
else { else {
@ -10,7 +10,7 @@ pub fn escape<'a>(string: String, bits: &mut Vec<ANSIString<'a>>, good: Style, b
// The `escape_default` method on `char` is *almost* what we want here, but // The `escape_default` method on `char` is *almost* what we want here, but
// it still escapes non-ASCII UTF-8 characters, which are still printable. // it still escapes non-ASCII UTF-8 characters, which are still printable.
if c >= 0x20 as char { if c >= 0x20 as char && c != 0x7f as char {
// TODO: This allocates way too much, // TODO: This allocates way too much,
// hence the `all` check above. // hence the `all` check above.
let mut s = String::new(); let mut s = String::new();