nushell/crates/nu-explore/src/nu_common/string.rs
Maxim Zhiburt 99caad7d60
nu-explore: Refactorings (#10247)
1. Added mode to the status bar right most corner
2. Added a command name with a status when run

ref #8582 
cc: @fdncred
2023-09-06 13:24:24 -05:00

17 lines
330 B
Rust

use nu_table::string_truncate;
pub use nu_table::string_width;
pub fn truncate_str(text: &mut String, width: usize) {
if width == 0 {
text.clear();
} else {
if string_width(text) < width {
return;
}
*text = string_truncate(text, width - 1);
text.push('…');
}
}