mirror of
https://github.com/sreedevk/deduplicator.git
synced 2026-09-14 01:26:33 +00:00
Take 32 grapheme clusters instead of characters
This commit is contained in:
@@ -24,3 +24,4 @@ sqlite = "0.30.3"
|
|||||||
thiserror = "1.0.38"
|
thiserror = "1.0.38"
|
||||||
tokio = { version = "1.23.0", features = ["full"] }
|
tokio = { version = "1.23.0", features = ["full"] }
|
||||||
tui = "0.19.0"
|
tui = "0.19.0"
|
||||||
|
unicode-segmentation = "1.10.0"
|
||||||
|
|||||||
@@ -12,14 +12,16 @@ use crate::app::file_manager;
|
|||||||
use crate::database::File;
|
use crate::database::File;
|
||||||
use crate::params::Params;
|
use crate::params::Params;
|
||||||
use prettytable::{format, row, Cell, Row, Table};
|
use prettytable::{format, row, Cell, Row, Table};
|
||||||
|
use unicode_segmentation::UnicodeSegmentation;
|
||||||
|
|
||||||
fn format_path(path: &str, opts: &Params) -> Result<String> {
|
fn format_path(path: &str, opts: &Params) -> Result<String> {
|
||||||
let display_path = path.replace(&opts.get_directory()?, "");
|
let display_path = path.replace(&opts.get_directory()?, "");
|
||||||
let text_vec = display_path.chars().collect::<Vec<_>>();
|
|
||||||
|
|
||||||
let display_range = if text_vec.len() < 32 {
|
let display_range = if display_path.chars().count() > 32 {
|
||||||
text_vec
|
display_path
|
||||||
.iter()
|
.graphemes(true)
|
||||||
|
.collect::<Vec<&str>>()
|
||||||
|
.into_iter()
|
||||||
.rev()
|
.rev()
|
||||||
.take(32)
|
.take(32)
|
||||||
.rev()
|
.rev()
|
||||||
|
|||||||
Reference in New Issue
Block a user