From 9afc9295a710f5bb0d951bc1243f613d6fc49fe2 Mon Sep 17 00:00:00 2001 From: Trevor Brown Date: Thu, 5 Nov 2026 14:19:44 -0500 Subject: [PATCH] Toolbar order applies to Shift-switch cycling only; plain letters keep their order (#11376) With "Use Shift Key for Tool Switch" off, plain letters cycle the group, and that case was not measured. The toolbar-order sort now runs only when the preference is on; with it off the group keeps its Tool::ALL order. A test pins plain W from Magic Wand going Quick Selection, Object Selection, Magic Wand. Co-Authored-By: Claude Fable 5.1 --- crates/ui-egui/src/input/shortcuts.rs | 7 +++++-- .../src/tool_shift_cycle_order_tests.rs | 21 +++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/input/shortcuts.rs b/crates/ui-egui/src/input/shortcuts.rs index 52b2a1cc413..b4c00690ccb 100644 --- a/crates/ui-egui/src/input/shortcuts.rs +++ b/crates/ui-egui/src/input/shortcuts.rs @@ -906,8 +906,11 @@ fn select_tool_by_key(app: &mut PhotocraftApp, ctx: &egui::Context, pressed: &im if cycle_shift || pressed(k) { let before = app.ui.tool; let mut group: Vec = Tool::ALL.iter().copied().filter(|x| x.key() == t.key() && crate::tool_shortcuts::uses_default(app, *x)).collect(); - // Shift+key steps in the toolbar flyout's order, not the order of `Tool::ALL`. - group.sort_by_key(|x| crate::panels::toolbar::toolbar_position(*x)); + // With the Shift-switch preference, Shift+key steps in the toolbar flyout's order; with it off + // plain keys keep the `Tool::ALL` order. + if shift_switch { + group.sort_by_key(|x| crate::panels::toolbar::toolbar_position(*x)); + } app.ui.tool = match group.iter().position(|x| *x == app.ui.tool) { Some(i) if shift_switch && !cycle_shift => group[i], Some(i) => group[(i + 1) % group.len()], diff --git a/crates/ui-egui/src/tool_shift_cycle_order_tests.rs b/crates/ui-egui/src/tool_shift_cycle_order_tests.rs index 1f1d4885b85..017f3777fe4 100644 --- a/crates/ui-egui/src/tool_shift_cycle_order_tests.rs +++ b/crates/ui-egui/src/tool_shift_cycle_order_tests.rs @@ -126,3 +126,24 @@ fn the_cycle_order_is_the_flattened_toolbar_order() { assert_eq!(toolbar_position(*t), i, "{t:?}"); } } + +#[test] +fn with_the_shift_switch_preference_off_plain_w_keeps_the_old_order() { + let mut app = app(); + app.session.edit_prefs(|p| p.tools.use_shift_key_for_tool_switch = false); + app.ui.tool = Tool::MagicWand; + let mut seen = Vec::new(); + for _ in 0..3 { + let ctx = egui::Context::default(); + let modifiers = Modifiers::NONE; + let raw = egui::RawInput { + events: vec![egui::Event::Key { key: Key::W, physical_key: None, pressed: true, repeat: false, modifiers }], + ..Default::default() + }; + ctx.begin_pass(raw); + crate::shortcuts::handle(&mut app, &ctx); + ctx.end_pass().textures_delta.clear(); + seen.push(app.ui.tool); + } + assert_eq!(seen, vec![Tool::QuickSelection, Tool::ObjectSelection, Tool::MagicWand]); +}