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 1, 2022
1 parent a1105b3 commit 9159cbd
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 @@ -990,9 +990,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 @@ -1080,7 +1091,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 9159cbd

Please sign in to comment.