From 87870c6802587d808136ddc6991870f7b1b387f0 Mon Sep 17 00:00:00 2001 From: Hector Villarreal Date: Sun, 8 Nov 2026 01:38:25 -0600 Subject: [PATCH] Mixer Brush switches: a toggle by key moves the brush revision so it is saved (CodeRabbit review on crates/engine/src/cmd/brush_cmds.rs:825) Without it, a switch flipped by its shortcut and nothing else before quitting was not written to the last-brush preferences. Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/cmd/brush_cmds.rs | 5 ++++- crates/engine/src/mixer_toggle_commands_tests.rs | 12 ++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/cmd/brush_cmds.rs b/crates/engine/src/cmd/brush_cmds.rs index 7e737f7a7a..3b53724c08 100644 --- a/crates/engine/src/cmd/brush_cmds.rs +++ b/crates/engine/src/cmd/brush_cmds.rs @@ -822,7 +822,10 @@ fn mixer_toggle(s: &mut Session, p: &Value, cmd: &str) -> Result { }; let value = field(&mut s.tools.brush.mixer); *value = on.unwrap_or(!*value); - Ok(json!({ "on": *value })) + let on = *value; + // Saved like any other brush change (the last-brush persistence watches the revision). + s.tools.brush_changed(); + Ok(json!({ "on": on })) } /// `paint.mixerLoad`: ⌥-click with the Mixer Brush loads the reservoir from the canvas colour at diff --git a/crates/engine/src/mixer_toggle_commands_tests.rs b/crates/engine/src/mixer_toggle_commands_tests.rs index ab20ca11e8..910b8b6af1 100644 --- a/crates/engine/src/mixer_toggle_commands_tests.rs +++ b/crates/engine/src/mixer_toggle_commands_tests.rs @@ -67,3 +67,15 @@ fn keyboard_shortcuts_list_the_five_without_keys_and_can_assign_one() { assert_eq!(row(id)["label"], label); } } + +/// A switch flipped by its key is saved like any other brush change: it moves the brush revision +/// the last-brush persistence watches (CodeRabbit review on brush_cmds.rs:825). +#[test] +fn each_switch_marks_the_brush_changed_so_it_is_saved() { + let mut s = Session::new(); + for (id, _) in SWITCHES { + let rev = s.tools.brush_rev; + s.execute(id, json!({})).unwrap(); + assert_ne!(s.tools.brush_rev, rev, "{id} moves the brush revision"); + } +}