Browse Source

fixed char limit (#3173)

pull/3181/head
Serv 1 year ago
committed by GitHub
parent
commit
339b758c60
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      crates/egui/src/widgets/text_edit/builder.rs

2
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,

Loading…
Cancel
Save