From ce9b5372d9ffffbc7ee133292172d31a65dfe72b Mon Sep 17 00:00:00 2001 From: ClementTsang Date: Thu, 27 Feb 2020 16:15:21 -0500 Subject: [PATCH] Use max grapheme length rather than max "string" length. --- src/app.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/app.rs b/src/app.rs index 1f983e32..3ab99662 100644 --- a/src/app.rs +++ b/src/app.rs @@ -9,6 +9,7 @@ use crate::{canvas, constants, utils::error::Result}; mod process_killer; use unicode_segmentation::GraphemeCursor; +use unicode_width::UnicodeWidthStr; const MAX_SEARCH_LENGTH: usize = 200; @@ -818,11 +819,12 @@ impl App { self.last_key_press = current_key_press_inst; if let WidgetPosition::ProcessSearch = self.current_widget_selected { - if self - .process_search_state - .search_state - .current_search_query - .len() <= MAX_SEARCH_LENGTH + if UnicodeWidthStr::width_cjk( + self.process_search_state + .search_state + .current_search_query + .as_str(), + ) <= MAX_SEARCH_LENGTH { self.process_search_state .search_state