mirror of
https://github.com/storytold/figcraft.git
synced 2026-10-25 19:06:47 -06:00
fix(ui): paste chords read modifiers from modifier changes only (#716)
Every shell reports a modifier change before the key it goes with, so key events needn't update the held modifiers too. The old test that pressed Shift+Cmd+V and Alt+Cmd+V expecting "nothing" now covers plain V only: those chords run their commands, covered by their own tests. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
9f52819fe9
commit
18a7a063fe
@@ -502,7 +502,8 @@ pub struct UiState {
|
||||
pub paste_event: bool,
|
||||
/// The window got the focus back since the last V release.
|
||||
pub refocused: bool,
|
||||
/// The modifiers held, as of the last raw event that told: a paste event doesn't carry them.
|
||||
/// The modifiers held, as of the last modifier change in the raw events: a paste event doesn't
|
||||
/// carry them.
|
||||
pub held: egui::Modifiers,
|
||||
/// When (UI clock, seconds) open documents next get an autosave checkpoint.
|
||||
pub next_autosave: f64,
|
||||
|
||||
@@ -231,13 +231,11 @@ fn the_browser_sequence_pastes_once() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn v_alone_and_other_paste_commands_paste_nothing() {
|
||||
fn v_alone_pastes_nothing() {
|
||||
let mut w = Win::new();
|
||||
w.copy_image_elsewhere();
|
||||
w.frame(vec![key(Key::V, true, Modifiers::NONE)]);
|
||||
w.frame(vec![key(Key::V, false, Modifiers::NONE)]);
|
||||
w.cmd_v(CMD.plus(Modifiers::SHIFT));
|
||||
w.cmd_v(CMD.plus(Modifiers::ALT));
|
||||
assert_eq!(w.named("Pasted image"), 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -163,9 +163,6 @@ pub fn swallowed_paste(app: &mut FigApp, ctx: &Context) -> Swallowed {
|
||||
let mut out = Swallowed::default();
|
||||
ctx.input(|i| {
|
||||
for ev in &i.raw.events {
|
||||
if let Event::Key { modifiers, .. } = ev {
|
||||
ui.held = *modifiers;
|
||||
}
|
||||
match ev {
|
||||
Event::ModifiersChanged(m) => ui.held = *m,
|
||||
// Without Cmd/Ctrl held it's another paste key (Shift+Insert, a Paste key).
|
||||
|
||||
Reference in New Issue
Block a user