| skipped 11 lines |
12 | 12 | | use crate::database::File; |
13 | 13 | | use crate::params::Params; |
14 | 14 | | use prettytable::{format, row, Cell, Row, Table}; |
| 15 | + | use unicode_segmentation::UnicodeSegmentation; |
15 | 16 | | |
16 | 17 | | fn format_path(path: &str, opts: &Params) -> Result<String> { |
17 | 18 | | let display_path = path.replace(&opts.get_directory()?, ""); |
18 | | - | let text_vec = display_path.chars().collect::<Vec<_>>(); |
19 | 19 | | |
20 | | - | let display_range = if text_vec.len() > 32 { |
21 | | - | text_vec[(display_path.len() - 32)..] |
22 | | - | .iter() |
23 | | - | .collect::<String>() |
| 20 | + | let display_range = if display_path.chars().count() > 32 { |
| 21 | + | display_path |
| 22 | + | .graphemes(true) |
| 23 | + | .collect::<Vec<&str>>() |
| 24 | + | .into_iter() |
| 25 | + | .rev() |
| 26 | + | .take(32) |
| 27 | + | .rev() |
| 28 | + | .collect() |
24 | 29 | | } else { |
25 | 30 | | display_path |
26 | 31 | | }; |
| skipped 140 lines |