mirror of
https://github.com/emilk/egui.git
synced 2026-08-31 13:50:04 -04:00
Fix(egui-winit): only ignore invalid range instead of whole Ime::Preedit event
This commit is contained in:
@@ -691,14 +691,15 @@ impl State {
|
|||||||
winit::event::Ime::Preedit(text, active_range_bytes) => {
|
winit::event::Ime::Preedit(text, active_range_bytes) => {
|
||||||
let active_range_chars = match *active_range_bytes {
|
let active_range_chars = match *active_range_bytes {
|
||||||
Some((start_bytes, end_bytes)) => {
|
Some((start_bytes, end_bytes)) => {
|
||||||
let (Some(start_chars), Some(middle_chars)) = (
|
if let (Some(start_chars), Some(middle_chars)) = (
|
||||||
text.get(..start_bytes).map(|s| s.chars().count()),
|
text.get(..start_bytes).map(|s| s.chars().count()),
|
||||||
text.get(start_bytes..end_bytes).map(|s| s.chars().count()),
|
text.get(start_bytes..end_bytes).map(|s| s.chars().count()),
|
||||||
) else {
|
) {
|
||||||
log::warn!("{ime:?} is ignored due to invalid range");
|
Some(start_chars..start_chars + middle_chars)
|
||||||
return;
|
} else {
|
||||||
};
|
log::warn!("ignoring {ime:?}'s range because it is invalid");
|
||||||
Some(start_chars..start_chars + middle_chars)
|
None
|
||||||
|
}
|
||||||
}
|
}
|
||||||
None => None,
|
None => None,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user