Clear stale Find Font warning after successful replacement

This commit is contained in:
dotCooCoo
2026-11-04 08:12:15 +07:00
committed by bflatastic
parent 1ad74d1ddf
commit 9250f2bfe6
2 changed files with 17 additions and 1 deletions
+6
View File
@@ -188,6 +188,12 @@ impl VectorcraftApp {
r.insert(0, font.to_string());
r.truncate(MAX_RECENT_FONTS);
}
if id == "text.replaceFont"
&& v.get("warning").is_none()
&& self.ui.status.starts_with("some text is hidden or locked, so its font wasn't replaced")
{
self.ui.status.clear();
}
// A command's warning (Rasterize's when an image couldn't be decoded) shows in the
// status bar, as a tool preview's does.
if let Some(w) = v.get("warning").and_then(Value::as_str) {
+11 -1
View File
@@ -286,7 +286,7 @@ mod tests {
/// Change All leaves locked text in its font, and the status bar says so.
#[test]
fn change_all_says_when_locked_text_keeps_its_font() {
fn change_all_clears_the_skip_warning_after_unlocking_text() {
let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default());
app.session.execute("file.new", &json!({"width": 100, "height": 100})).unwrap();
app.session.execute("text.create", &json!({"x": 10, "y": 40, "text": "Hi", "font": "Missing Family"})).unwrap();
@@ -298,6 +298,16 @@ mod tests {
assert_eq!(r["runs"], 0, "{r}");
assert_eq!(fonts(&mut app)[0]["family"], "Missing Family");
assert_eq!(app.ui.status, "some text is hidden or locked, so its font wasn't replaced");
app.run("object.unlockAll", json!({})).unwrap();
assert_eq!(app.ui.status, "some text is hidden or locked, so its font wasn't replaced");
let r = change(&mut app, &d, &from, true).unwrap();
assert_eq!(r["runs"], 1, "{r}");
assert!(r.get("warning").is_none(), "{r}");
assert_eq!(app.ui.status, "");
app.ui.status = "Saved another document".into();
let r = app.run("text.replaceFont", json!({"from": {"family": "Missing Family"}, "to": {"family": "Source Sans 3"}})).unwrap();
assert_eq!(r["runs"], 0, "{r}");
assert_eq!(app.ui.status, "Saved another document");
}
#[test]