mirror of
https://github.com/denisidoro/navi
synced 2024-11-21 19:13:07 +00:00
Fix padding (#822)
This commit is contained in:
parent
f6414551bb
commit
4f63f30ed7
1 changed files with 2 additions and 2 deletions
|
@ -34,11 +34,11 @@ fn limit_str(text: &str, length: usize) -> String {
|
||||||
let mut new_length = length;
|
let mut new_length = length;
|
||||||
let mut actual_length = 9999;
|
let mut actual_length = 9999;
|
||||||
let mut txt = text.to_owned();
|
let mut txt = text.to_owned();
|
||||||
while actual_length > length {
|
while actual_length >= length {
|
||||||
txt = txt.chars().take(new_length - 1).collect::<String>();
|
txt = txt.chars().take(new_length - 1).collect::<String>();
|
||||||
actual_length = UnicodeWidthStr::width(txt.as_str());
|
actual_length = UnicodeWidthStr::width(txt.as_str());
|
||||||
new_length -= 1;
|
new_length -= 1;
|
||||||
}
|
}
|
||||||
format!("{}…", txt)
|
format!("{}…{}", txt, " ".repeat(length - actual_length - 1))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue