Fix panic when trimming text with non-ASCII characters (#311)

Fixes #310
This commit is contained in:
Denis Isidoro 2020-03-24 10:53:45 -03:00 committed by GitHub
parent 4b5658a5b7
commit 04dcf79a34
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -51,7 +51,7 @@ pub fn preview(comment: &str, tags: &str, snippet: &str) {
fn limit_str(text: &str, length: usize) -> String {
if text.len() > length {
format!("{}", &text[..length - 1])
format!("{}", text.chars().take(length).collect::<String>())
} else {
format!("{:width$}", text, width = length)
}