From bdf052a5bcb8941f43212caab3dc3c7b6b75dfd5 Mon Sep 17 00:00:00 2001 From: skylartaylor Date: Wed, 25 Nov 2026 23:22:35 +0100 Subject: [PATCH] tests: unbind the library's Paste in the trial that keeps both pastes A paste with nothing focused stands for Cmd+V, which the library's own Paste command binds by default, so the command took both pastes and the host that reads what nothing took got none. The trial unbinds it, as the native float trial does, so no command is bound and both pastes are the host's. --- crates/ui-contract/tests/it/runtime/leftover_events.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/ui-contract/tests/it/runtime/leftover_events.rs b/crates/ui-contract/tests/it/runtime/leftover_events.rs index 4c05611f25..efe4f2c776 100644 --- a/crates/ui-contract/tests/it/runtime/leftover_events.rs +++ b/crates/ui-contract/tests/it/runtime/leftover_events.rs @@ -1,7 +1,8 @@ //! `runtime::keys::leftover_events`: the keys of a pass that nothing took, for a host that runs shortcuts of its own on //! a window's input. -use craft_ui::runtime::commands::{AppCatalog, Binding, CommandDef, CommandInput, Scope}; +use craft_keymap::Overrides; +use craft_ui::runtime::commands::{AppCatalog, Binding, CommandDef, CommandInput, CommandSet as _, EditCommands, Scope}; use craft_ui::runtime::frame::take_output; use craft_ui::runtime::keys::leftover_events; use craft_ui::testing::focus::key_release; @@ -9,6 +10,7 @@ use craft_ui::testing::input::{key_press, key_repeat, text}; use craft_ui::testing::{Frames, trial}; use egui::{Event, Key, Modifiers, Ui}; use std::cell::{Cell, RefCell}; +use std::sync::Arc; /// The presses and releases of `events`, in order, each with whether it is a press. fn key_events(events: Vec) -> Vec<(Key, bool)> { @@ -54,6 +56,11 @@ fn leftover_events_holds_the_keys_no_command_took() { #[trial] fn leftover_events_holds_both_pastes_of_a_pass() { let mut frames = Frames::new(); + // The library's own Paste is bound to Cmd+V by default, and a paste with nothing focused stands for that chord: the + // trial unbinds it, so no command takes the pastes, as in a window that runs no Paste of its own. + let mut unbound = Overrides::new(); + unbound.insert(EditCommands::Paste.id(), Vec::new()); + frames.commands(CommandInput::new().overrides(Arc::new(unbound))); let left = RefCell::new(Vec::new()); let mut show = |ui: &mut Ui| { left.borrow_mut().extend(leftover_events(ui.ctx()));