Color Replacement: the hidden-layer alert is for pixel targets only (CodeRabbit on #16279)

Test: a_hidden_layer_with_a_mask_target_keeps_the_status_bar_message.
This commit is contained in:
Hector Villarreal committed 2026-11-21 14:39:34 -06:00
1 parent c8aa94678e
commit 8796c756dd
2 files changed
+18 -1

No files matched your search

@@ -18,6 +18,20 @@ fn a_hidden_target_layer() {
assert_eq!(photocraft_engine::hidden_target::HIDDEN, "Could not complete your request because the target layer is hidden.", "the shared text is unchanged");
}
/// A targeted layer mask on a hidden layer keeps the status-bar refusal: only a pixel target gets the alert (CodeRabbit
/// on #16279).
#[test]
fn a_hidden_layer_with_a_mask_target_keeps_the_status_bar_message() {
let mut app = app(Tool::ColorReplacement);
app.run("layer.layerMask.revealAll", json!({})).unwrap();
let id = active(&app);
app.run("layer.setProps", json!({"layer": id, "visible": false})).unwrap();
app.ui.mask_target = true;
stroke(&mut app);
assert!(alerts(&app).is_empty(), "no alert: {:?}", alerts(&app));
assert!(app.ui.status_error, "the status bar says it: {:?}", app.ui.status);
}
#[test]
fn lock_all() {
let mut app = app(Tool::ColorReplacement);
+4 -1
View File
@@ -85,7 +85,10 @@ pub fn alert(app: &PhotocraftApp, tool: Tool, hidden: bool) -> Option<String> {
return (!hidden && pixel_layer && layer_refusal(app, tool) == Some(LOCKED)).then(|| tl!(REMOVE_LOCKED).to_string());
}
let name = tool_name(app, tool)?;
let template = if hidden { HIDDEN } else { layer_refusal(app, tool)? };
// The Color Replacement tool's hidden-layer alert is for a pixel target only: a mask target keeps the status-bar
// message it had (CodeRabbit on #16279).
let hidden_alert = hidden && (tool != Tool::ColorReplacement || crate::canvas::paint_target(app) == json!("pixels"));
let template = if hidden_alert { HIDDEN } else { layer_refusal(app, tool)? };
// The Color Replacement tool says a group differently (#11924).
let template = if tool == Tool::ColorReplacement && template == GROUP { TARGET_GROUP } else { template };
Some(crate::i18n::fmt(tl!(template), &[("tool", name)]))