Skip to content

Commit

Permalink
Fix panic when trimming text with non-ASCII characters (#311)
Browse files Browse the repository at this point in the history
Fixes #310
  • Loading branch information
denisidoro authored Mar 24, 2020
1 parent 4b5658a commit 04dcf79
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 04dcf79

Please sign in to comment.