diff --git a/Cargo.lock b/Cargo.lock index 862bbdb..7b7a3f2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -316,7 +316,7 @@ dependencies = [ [[package]] name = "deduplicator" -version = "0.0.8" +version = "0.0.9" dependencies = [ "anyhow", "chrono", @@ -334,6 +334,7 @@ dependencies = [ "thiserror", "tokio", "tui", + "unicode-segmentation", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 3e7b5a3..a38c053 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "deduplicator" -version = "0.0.8" +version = "0.0.9" edition = "2021" description = "find,filter,delete Duplicates" license = "MIT" @@ -25,3 +25,4 @@ sqlite = "0.30.3" thiserror = "1.0.38" tokio = { version = "1.23.0", features = ["full"] } tui = "0.19.0" +unicode-segmentation = "1.10.0" diff --git a/src/output.rs b/src/output.rs index 74a1282..fcc2518 100644 --- a/src/output.rs +++ b/src/output.rs @@ -12,15 +12,20 @@ use crate::app::file_manager; use crate::database::File; use crate::params::Params; use prettytable::{format, row, Cell, Row, Table}; +use unicode_segmentation::UnicodeSegmentation; fn format_path(path: &str, opts: &Params) -> Result { let display_path = path.replace(&opts.get_directory()?, ""); - let text_vec = display_path.chars().collect::>(); - let display_range = if text_vec.len() > 32 { - text_vec[(display_path.len() - 32)..] - .iter() - .collect::() + let display_range = if display_path.chars().count() > 32 { + display_path + .graphemes(true) + .collect::>() + .into_iter() + .rev() + .take(32) + .rev() + .collect() } else { display_path };