1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-26 22:53:14 -04:00

Fix(egui): workaround Windows buitlin Korean IME cursor position bug

This commit is contained in:
umajho
2026-04-09 16:44:40 +08:00
parent 7b0e45c6b8
commit 4b35b97319

View File

@@ -137,13 +137,27 @@ pub(crate) fn paint_ime_preedit_text_visuals(
galley: &Arc<Galley>,
row_height: f32,
preedit_range: std::ops::Range<CCursor>,
relative_active_range: Option<std::ops::Range<CCursor>>,
mut relative_active_range: Option<std::ops::Range<CCursor>>,
time_since_last_interaction: f64,
) {
if preedit_range.is_empty() {
return;
}
if cfg!(target_os = "windows")
&& let Some(r) = &relative_active_range
&& r.start.index == 0
&& r.end.index == 0
{
// Workaround for a bug on Windows where `winit` incorrectly reports
// the cursor position at the start of the preedit text during
// composition with the builtin Korean IME.
// See: https://github.com/emilk/egui/pull/8083#issuecomment-4206742668
// TODO(umajho): Remove this workaround once the `winit` bug is fixed
// and we've updated to a version that includes the fix.
relative_active_range = None;
}
let visuals = ui.visuals();
let active_underline_stroke = visuals.ime_preedit.active_underline_stroke;
let inactive_underline_stroke = visuals.ime_preedit.inactive_underline_stroke;