Skip to content

Commit

Permalink
Replace Debug formatting with minimal escaping
Browse files Browse the repository at this point in the history
  • Loading branch information
wetheredge committed Oct 4, 2022
1 parent 4e0f995 commit c3e2dfd
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions helix-term/src/commands/typed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1014,9 +1014,20 @@ fn get_character_info(
}

let grapheme = text.slice(grapheme_start..grapheme_end).to_string();

let encoding = doc.encoding();

let printable = grapheme.chars().fold(String::new(), |mut s, c| {
match c {
'\0' => s.push_str("\\0"),
'\t' => s.push_str("\\t"),
'\n' => s.push_str("\\n"),
'\r' => s.push_str("\\r"),
_ => s.push(c),
}

s
});

// Convert to Unicode codepoints if in UTF-8
let unicode = if encoding == encoding::UTF_8 {
let mut unicode = " (".to_owned();
Expand Down Expand Up @@ -1104,7 +1115,7 @@ fn get_character_info(
};

cx.editor
.set_status(format!("{grapheme:?}{unicode}{dec} Hex{hex}"));
.set_status(format!("\"{printable}\"{unicode}{dec} Hex{hex}"));

Ok(())
}
Expand Down

0 comments on commit c3e2dfd

Please sign in to comment.