diff --git a/crates/egui/src/text_selection/visuals.rs b/crates/egui/src/text_selection/visuals.rs index b43325758..7109df2eb 100644 --- a/crates/egui/src/text_selection/visuals.rs +++ b/crates/egui/src/text_selection/visuals.rs @@ -137,13 +137,27 @@ pub(crate) fn paint_ime_preedit_text_visuals( galley: &Arc, row_height: f32, preedit_range: std::ops::Range, - relative_active_range: Option>, + mut relative_active_range: Option>, 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;