Fix of "thread 'main' panicked at 'range start index 130 out of range for slice of length 104', src/output.rs:21:9"

This commit is contained in:
Andrey Ryabov
2023-01-11 23:01:10 +02:00
parent 06efb2ed6f
commit 2294471b50

View File

@@ -17,10 +17,13 @@ fn format_path(path: &str, opts: &Params) -> Result<String> {
let display_path = path.replace(&opts.get_directory()?, "");
let text_vec = display_path.chars().collect::<Vec<_>>();
let display_range = if text_vec.len() > 32 {
text_vec[(display_path.len() - 32)..]
let display_range = if text_vec.len() < 32 {
text_vec
.iter()
.collect::<String>()
.rev()
.take(32)
.rev()
.collect()
} else {
display_path
};