From 339b758c60d04688e7b53cd964473524650036e8 Mon Sep 17 00:00:00 2001 From: Serv Date: Wed, 26 Jul 2023 22:21:28 +0400 Subject: [PATCH] fixed char limit (#3173) --- crates/egui/src/widgets/text_edit/builder.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/egui/src/widgets/text_edit/builder.rs b/crates/egui/src/widgets/text_edit/builder.rs index b76c6e336..c9eaa1d4b 100644 --- a/crates/egui/src/widgets/text_edit/builder.rs +++ b/crates/egui/src/widgets/text_edit/builder.rs @@ -1185,7 +1185,7 @@ fn insert_text( if char_limit < usize::MAX { let mut new_string = text_to_insert; // Avoid subtract with overflow panic - let cutoff = char_limit.saturating_sub(text.as_str().len()); + let cutoff = char_limit.saturating_sub(text.as_str().chars().count()); new_string = match new_string.char_indices().nth(cutoff) { None => new_string,