From 2a09d78972897dc0591c72c94f97713c756252ce Mon Sep 17 00:00:00 2001 From: Lucas Batista Vargas Date: Wed, 25 Nov 2026 12:37:26 -0300 Subject: [PATCH] test(keys): restore the_ignored_paste_uses_up_its_paste_modifiers test (#7317) (#7609) --- crates/ui-egui/src/keys/tests.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/crates/ui-egui/src/keys/tests.rs b/crates/ui-egui/src/keys/tests.rs index 80a78e7714..d2f16a5c8b 100644 --- a/crates/ui-egui/src/keys/tests.rs +++ b/crates/ui-egui/src/keys/tests.rs @@ -284,6 +284,31 @@ fn copied_bold_app() -> WordApp { a } +/// #5616: after Mod+Shift+V (Paste Formatting) and a paired browser paste event, a later +/// menu-bar paste (`Event::Paste`) with no key or pointer press in between still keeps source +/// formatting instead of reading the earlier Mod+Shift as Keep Text Only. +#[test] +fn the_ignored_paste_uses_up_its_paste_modifiers() { + let mut h = app_harness(copied_bold_app()); + let chord = Modifiers { shift: true, ..mod_held() }; + batch_frame(&mut h, vec![egui::Event::ModifiersChanged(chord), key_event(Key::V, true, chord), egui::Event::Paste("x".into())]); + crate::test_harness::frame(&mut h); + assert_eq!(body(h.state()), "source target"); + assert!(is_bold(&mut h)); + run(&mut h, "select.text", json!({"text": "target"})); + offer(&h, vec![ClipItem::Html("

menu

".into()), ClipItem::Text("menu".into())]); + batch_frame(&mut h, vec![egui::Event::Paste("menu".into())]); + crate::test_harness::frame(&mut h); + assert_eq!(body(h.state()), "source menu"); + let state = run(&mut h, "format.state", json!({})); + assert_ne!( + state.get("bold").and_then(serde_json::Value::as_bool), + Some(true), + "a later menu-bar paste does not inherit target's bold via Keep Text Only: {state}" + ); + assert_eq!(state.get("italic").and_then(serde_json::Value::as_bool), Some(true), "a later menu-bar paste keeps clipboard formatting: {state}"); +} + /// Paste Formatting on a chord the user bound pastes the copied formatting once. #[test] fn paste_formatting_on_another_key_pastes_the_copied_formatting() {