Skip to content

Commit

Permalink
fixed char limit (#3173)
Browse files Browse the repository at this point in the history
  • Loading branch information
Serverator committed Jul 26, 2023
1 parent 65eecde commit 339b758
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion crates/egui/src/widgets/text_edit/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 339b758

Please sign in to comment.