mirror of
https://github.com/denisidoro/navi.git
synced 2026-08-01 14:33:52 +00:00
Fix panic when trimming text with non-ASCII characters (#311)
Fixes #310
This commit is contained in:
parent
4b5658a5b7
commit
04dcf79a34
1 changed files with 1 additions and 1 deletions
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue