From 2294471b506630469b1f56ffa599b60e943e991f Mon Sep 17 00:00:00 2001 From: Andrey Ryabov Date: Wed, 11 Jan 2023 23:01:10 +0200 Subject: [PATCH 1/3] Fix of "thread 'main' panicked at 'range start index 130 out of range for slice of length 104', src/output.rs:21:9" --- src/output.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/output.rs b/src/output.rs index 74a1282..ff216f7 100644 --- a/src/output.rs +++ b/src/output.rs @@ -17,10 +17,13 @@ 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)..] + let display_range = if text_vec.len() < 32 { + text_vec .iter() - .collect::() + .rev() + .take(32) + .rev() + .collect() } else { display_path }; From b736853dfe76f14e6b72eda2e4dd3dc09410fc5b Mon Sep 17 00:00:00 2001 From: Andrey Ryabov Date: Thu, 12 Jan 2023 21:43:31 +0200 Subject: [PATCH 2/3] Take 32 grapheme clusters instead of characters --- Cargo.toml | 1 + src/output.rs | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ba61aac..855b7f0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,3 +24,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 ff216f7..fcc2518 100644 --- a/src/output.rs +++ b/src/output.rs @@ -12,14 +12,16 @@ 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 - .iter() + let display_range = if display_path.chars().count() > 32 { + display_path + .graphemes(true) + .collect::>() + .into_iter() .rev() .take(32) .rev() From 64d01067657703278af6de06122b0f21deadd11c Mon Sep 17 00:00:00 2001 From: sreedev Date: Fri, 13 Jan 2023 00:53:46 -0500 Subject: [PATCH 3/3] version changes --- Cargo.lock | 3 ++- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) 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 b2badd1..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"