forked from 1b-agent/opencadstudio-upstream
style: rustfmt the tree so the CI lint check passes
This commit is contained in:
1 parent
1317a7b4fd
commit
6025d8be44
128 files changed
+4097
-1676
No files matched your search
+33
-35
@@ -862,7 +862,9 @@ impl OpenCADStudio {
|
||||
}
|
||||
}
|
||||
"grips" => self.control_grips(),
|
||||
"keytips" => self.ribbon.keytips_json(req["detail"].as_str() == Some("full")),
|
||||
"keytips" => self
|
||||
.ribbon
|
||||
.keytips_json(req["detail"].as_str() == Some("full")),
|
||||
"xdata_get" => self.xdata_read(&req),
|
||||
"get_selection" => self.control_get_selection(),
|
||||
"text_search" => self.control_text_search(&req).unwrap_or_else(|e| e),
|
||||
@@ -1356,14 +1358,9 @@ impl OpenCADStudio {
|
||||
pub(super) fn control_track(&mut self, task: Task<Message>) -> Task<Message> {
|
||||
let track_zero_unit = self.control.pending.as_ref().is_some_and(|p| {
|
||||
p.request["op"] == "run"
|
||||
&& p.request["cmd"]
|
||||
.as_str()
|
||||
.is_some_and(|cmd| {
|
||||
matches!(
|
||||
cmd.trim().to_ascii_uppercase().as_str(),
|
||||
"SAVE" | "QSAVE"
|
||||
)
|
||||
})
|
||||
&& p.request["cmd"].as_str().is_some_and(|cmd| {
|
||||
matches!(cmd.trim().to_ascii_uppercase().as_str(), "SAVE" | "QSAVE")
|
||||
})
|
||||
});
|
||||
// Most zero-unit tasks are `Task::none()` and have already completed
|
||||
// synchronously. SAVE/QSAVE are the deliberate exception: the command
|
||||
@@ -1870,10 +1867,7 @@ mod tests {
|
||||
.as_nanos(),
|
||||
));
|
||||
let _ = std::fs::remove_file(&path);
|
||||
let saved = request(
|
||||
&mut app,
|
||||
json!({"op":"save","path":path,"overwrite":true}),
|
||||
);
|
||||
let saved = request(&mut app, json!({"op":"save","path":path,"overwrite":true}));
|
||||
assert_eq!(saved["ok"], true, "{saved}");
|
||||
assert_eq!(
|
||||
request(&mut app, json!({"op":"run","cmd":"LINE 0,5 10,5"}))["status"],
|
||||
@@ -1910,10 +1904,7 @@ mod tests {
|
||||
));
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
let path = dir.join("blocked.dwg");
|
||||
let saved = request(
|
||||
&mut app,
|
||||
json!({"op":"save","path":path,"overwrite":true}),
|
||||
);
|
||||
let saved = request(&mut app, json!({"op":"save","path":path,"overwrite":true}));
|
||||
assert_eq!(saved["ok"], true, "{saved}");
|
||||
// A directory at the target path makes the next write fail
|
||||
// deterministically; the operation must settle as failed instead of
|
||||
@@ -1927,7 +1918,9 @@ mod tests {
|
||||
let qsave = request(&mut app, json!({"op":"run","cmd":"QSAVE"}));
|
||||
assert_eq!(qsave["status"], "failed", "{qsave}");
|
||||
assert!(
|
||||
qsave["error"].as_str().is_some_and(|error| !error.is_empty()),
|
||||
qsave["error"]
|
||||
.as_str()
|
||||
.is_some_and(|error| !error.is_empty()),
|
||||
"{qsave}"
|
||||
);
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
@@ -1951,7 +1944,10 @@ mod tests {
|
||||
}))
|
||||
.0;
|
||||
assert_eq!(parked["status"], "accepted", "{parked}");
|
||||
assert!(app.control.capture_frame_pending, "capture should wait for a frame");
|
||||
assert!(
|
||||
app.control.capture_frame_pending,
|
||||
"capture should wait for a frame"
|
||||
);
|
||||
let running = app
|
||||
.control_request(json!({"op":"operation","request_id":"cap-frame"}))
|
||||
.0;
|
||||
@@ -1959,11 +1955,8 @@ mod tests {
|
||||
|
||||
let _frame_task = app.on_control_capture_frame(true);
|
||||
assert!(!app.control.capture_frame_pending);
|
||||
let screenshot = iced::window::Screenshot::new(
|
||||
vec![0u8; 4 * 4 * 4],
|
||||
iced::Size::new(4, 4),
|
||||
1.0,
|
||||
);
|
||||
let screenshot =
|
||||
iced::window::Screenshot::new(vec![0u8; 4 * 4 * 4], iced::Size::new(4, 4), 1.0);
|
||||
app.control_screenshot(path.to_string_lossy().into_owned(), Some(screenshot));
|
||||
let done = app
|
||||
.control_request(json!({"op":"operation","request_id":"cap-frame"}))
|
||||
@@ -2040,14 +2033,13 @@ mod tests {
|
||||
let mut app = OpenCADStudio::new_for_test();
|
||||
request(&mut app, json!({"op":"new"}));
|
||||
request(&mut app, json!({"op":"run","cmd":"LINE 0,0 10,0"}));
|
||||
let handle = request(&mut app, json!({"op":"query","type":"Line"}))["entities"][0]["handle"]
|
||||
let handle = request(&mut app, json!({"op":"query","type":"Line"}))["entities"][0]
|
||||
["handle"]
|
||||
.as_str()
|
||||
.unwrap()
|
||||
.to_string();
|
||||
let before = app.control_state()["selection_revision"].as_u64().unwrap();
|
||||
let selected = app.automation_op(&format!(
|
||||
r#"{{"op":"select","handles":["{handle}"]}}"#
|
||||
));
|
||||
let selected = app.automation_op(&format!(r#"{{"op":"select","handles":["{handle}"]}}"#));
|
||||
assert_eq!(selected["ok"], true, "{selected}");
|
||||
let state = app.control_state();
|
||||
assert_eq!(
|
||||
@@ -2056,7 +2048,10 @@ mod tests {
|
||||
"selection revision should increment once: {state}"
|
||||
);
|
||||
assert!(
|
||||
state["selection"].as_array().unwrap().contains(&json!(handle)),
|
||||
state["selection"]
|
||||
.as_array()
|
||||
.unwrap()
|
||||
.contains(&json!(handle)),
|
||||
"{state}"
|
||||
);
|
||||
let events = app.control_request(json!({"op":"events"})).0;
|
||||
@@ -2064,7 +2059,10 @@ mod tests {
|
||||
assert_eq!(last["kind"], "selection", "{events}");
|
||||
assert_eq!(last["document_id"], state["document_id"], "{events}");
|
||||
assert!(
|
||||
last["selection"].as_array().unwrap().contains(&json!(handle)),
|
||||
last["selection"]
|
||||
.as_array()
|
||||
.unwrap()
|
||||
.contains(&json!(handle)),
|
||||
"{events}"
|
||||
);
|
||||
}
|
||||
@@ -2268,7 +2266,10 @@ mod tests {
|
||||
fn pending_request_id_reuse_rejects_changed_payload() {
|
||||
let mut app = OpenCADStudio::new_for_test();
|
||||
app.main_window = Some(iced::window::Id::unique());
|
||||
assert_eq!(request(&mut app, json!({"op":"new"}))["status"], "completed");
|
||||
assert_eq!(
|
||||
request(&mut app, json!({"op":"new"}))["status"],
|
||||
"completed"
|
||||
);
|
||||
|
||||
let pending = request(
|
||||
&mut app,
|
||||
@@ -2290,10 +2291,7 @@ mod tests {
|
||||
);
|
||||
assert_eq!(changed["code"], "request_id_reused", "{changed}");
|
||||
assert!(
|
||||
changed["error"]
|
||||
.as_str()
|
||||
.unwrap()
|
||||
.contains("pending-reuse"),
|
||||
changed["error"].as_str().unwrap().contains("pending-reuse"),
|
||||
"{changed}"
|
||||
);
|
||||
|
||||
|
||||
Reference in new issue
Block a user