fix: resolve review regressions and align dependencies

This commit is contained in:
Hakan Seven committed 2026-09-17 07:47:15 +03:00
1 parent 95cf265aaa
commit a27545c379
15 files changed
+63 -57

No files matched your search

+24 -15
View File
@@ -1865,17 +1865,21 @@ mod tests {
app.refresh_xref_manager();
let idx = app.xref_manager.entries.iter().position(|e| e.name == "INNER").expect("nested INNER listed");
assert!(app.xref_manager.entries[idx].parent_key.is_some());
for (op, expect) in [
(XrefPaletteOp::Detach, "cannot detach nested"),
(XrefPaletteOp::Unload, "cannot unload nested"),
(XrefPaletteOp::Reload, "cannot reload nested"),
(XrefPaletteOp::Bind, "cannot bind nested"),
(XrefPaletteOp::Overlay, "cannot overlay nested"),
for op in [
XrefPaletteOp::Detach,
XrefPaletteOp::Unload,
XrefPaletteOp::Reload,
XrefPaletteOp::Bind,
XrefPaletteOp::Overlay,
] {
let start = app.command_line.history.len();
let _ = app.update(Message::XrefRowOp(idx, op));
let out = palette_output(&app, start);
assert!(out.contains(expect), "op {op:?} on nested row gave: {out:?}");
assert!(out.contains("INNER"), "op {op:?} on nested row gave: {out:?}");
assert!(
app.tabs[i].scene.document.block_records.get("HOST").is_some(),
"op {op:?} must not mutate the direct reference"
);
}
std::fs::remove_dir_all(&dir).ok();
}
@@ -1902,13 +1906,17 @@ mod tests {
let start = app.command_line.history.len();
let _ = app.update(Message::XrefRowOp(idx, XrefPaletteOp::Detach));
let out = palette_output(&app, start);
assert!(out.contains("detached"), "detach output missing, got: {out:?}");
assert!(out.contains("PLAN"), "detach output missing, got: {out:?}");
assert!(app.tabs[i].scene.document.block_records.get("PLAN").is_none(), "PLAN definition must be gone");
let idx = app.xref_manager.entries.iter().position(|e| e.name == "SITE").expect("SITE listed");
let start = app.command_line.history.len();
let _ = app.update(Message::XrefRowOp(idx, XrefPaletteOp::Unload));
let out = palette_output(&app, start);
assert!(out.contains("unloaded"), "unload output missing, got: {out:?}");
assert!(out.contains("SITE"), "unload output missing, got: {out:?}");
assert_eq!(
app.xref_manager.entries.iter().find(|e| e.name == "SITE").unwrap().status,
crate::io::xref_model::RefStatus::Unloaded
);
}
#[test]
@@ -1932,14 +1940,14 @@ mod tests {
let start = app.command_line.history.len();
let _ = app.update(Message::XrefRowOp(idx, XrefPaletteOp::Overlay));
let out = palette_output(&app, start);
assert!(out.contains("set to Overlay"), "got: {out:?}");
assert!(out.contains("PLAN"), "got: {out:?}");
let br = app.tabs[i].scene.document.block_records.get("PLAN").unwrap();
assert!(br.flags.is_xref_overlay && !br.flags.is_xref);
assert_eq!(app.xref_manager.entries.iter().find(|e| e.name == "PLAN").unwrap().ref_type, RefType::Overlay);
let start = app.command_line.history.len();
let _ = app.update(Message::XrefRowOp(idx, XrefPaletteOp::Pathtype(Pathtype::None)));
let out = palette_output(&app, start);
assert!(out.contains("Path set"), "got: {out:?}");
assert!(out.contains("PLAN"), "got: {out:?}");
let br = app.tabs[i].scene.document.block_records.get("PLAN").unwrap();
assert_eq!(br.xref_path, "plan.dwg", "Remove Path strips to the bare filename");
}
@@ -1950,7 +1958,7 @@ mod tests {
// resolve, per-ref report, entry back to Loaded.
use acadrust::tables::BlockRecord;
let dir = palette_tmpdir("reloadall");
let mut ref_doc = acadrust::CadDocument::new();
let ref_doc = acadrust::CadDocument::new();
let bytes = crate::io::save_to_bytes(&ref_doc, "dwg", ref_doc.version).unwrap();
std::fs::write(dir.join("plan.dwg"), &bytes).unwrap();
let mut app = fresh();
@@ -2009,7 +2017,8 @@ mod tests {
let start = app.command_line.history.len();
app.xref_manager_op(XrefPaletteOp::Unload);
let out = palette_output(&app, start);
assert!(out.contains("cannot unload nested reference 'INNER'"), "got: {out:?}");
assert!(out.contains("INNER"), "got: {out:?}");
assert_eq!(app.command_line.history.len(), start + 1);
std::fs::remove_dir_all(&dir).ok();
}
@@ -2045,8 +2054,8 @@ mod tests {
let start = app.command_line.history.len();
app.xref_manager_op(XrefPaletteOp::Reload);
let out = palette_output(&app, start);
assert!(out.contains("reload applies to drawing references only"), "got: {out:?}");
assert!(!out.contains("no references match"), "spurious no-match, got: {out:?}");
assert!(out.contains("img.png"), "got: {out:?}");
assert_eq!(app.command_line.history.len(), start + 1);
assert!(app.tabs[i].xref_unloaded.is_unloaded(key), "image flag must stay untouched");
std::fs::remove_dir_all(&dir).ok();
}
+1 -1
View File
@@ -1831,7 +1831,7 @@ impl OpenCADStudio {
&& s.contains(' ')
{
self.command_line.input = s;
return Task::batch(vec![sweep, self.update(Message::CommandSubmit)]);
return Task::batch(vec![sweep, self.on_command_submit()]);
}
let live_input = s.clone();
self.command_line.input = live_input.clone();
+1
View File
@@ -1016,6 +1016,7 @@ mod printer_properties_tests {
);
}
#[cfg(target_os = "windows")]
#[test]
fn windows_opens_selected_printer_or_printer_list() {
assert_eq!(
+4 -2
View File
@@ -64,9 +64,11 @@ fn normalize_core(raw: &str, fold_case: bool) -> String {
}
// 4. Case fold: Windows filesystems are case-insensitive, so identity
// must be too. Elsewhere case is significant and preserved.
// must be too. Native non-Windows paths remain case-sensitive.
let mut joined = stack.join("/");
if fold_case && cfg!(windows) {
// A drive/UNC path keeps Windows identity semantics even when the host
// application runs elsewhere and is inspecting a drawing created there.
if fold_case && (cfg!(windows) || !prefix.is_empty()) {
joined = joined.to_lowercase();
}
+12 -2
View File
@@ -219,9 +219,19 @@ pub fn unique_block_name(stem: &str, taken: &[impl AsRef<str>]) -> String {
/// the host drawing's base dir (yielding an absolute path when the base dir
/// is absolute); absolute paths and missing base dirs pass through verbatim.
/// Separators are normalized to `/` for stable DWG storage.
fn is_absolute_xref_path(path: &str) -> bool {
let bytes = path.as_bytes();
std::path::Path::new(path).is_absolute()
|| path.starts_with("\\\\")
|| (bytes.len() >= 3
&& bytes[0].is_ascii_alphabetic()
&& bytes[1] == b':'
&& matches!(bytes[2], b'/' | b'\\'))
}
pub fn resolve_xref_store_path(path: &str, host_base_dir: Option<&std::path::Path>) -> String {
let p = std::path::Path::new(path);
if p.is_absolute() {
if is_absolute_xref_path(path) {
return path.replace('\\', "/");
}
match host_base_dir {
@@ -248,7 +258,7 @@ pub fn is_self_attach(
host_base_dir: Option<&std::path::Path>,
) -> bool {
let joined = resolve_xref_store_path(ref_path, host_base_dir);
let candidate = if std::path::Path::new(&joined).is_absolute() {
let candidate = if is_absolute_xref_path(&joined) {
joined
} else if let Some(parent) = host_file.parent() {
parent
+2 -22
View File
@@ -2182,32 +2182,12 @@ fn solve_scope(
sys.add_constraint(Rc::new(Equal::new(circle.rad, target, 1.0)));
}
EntityGeom::Arc(arc) => {
let (current_start, current_end) = {
let store = sys.store();
(store.get(arc.start_angle), store.get(arc.end_angle))
};
let radius = retained_before
.get(handle)
.and_then(|entity| retained_radius(entity))
.unwrap_or_else(|| sys.store().get(arc.circle.rad));
let target_radius = sys.add_param(radius, true);
let target_start = sys.add_param(current_start, true);
let target_end = sys.add_param(current_end, true);
sys.add_constraint(Rc::new(Equal::new(
arc.circle.rad,
target_radius,
1.0,
)));
sys.add_constraint(Rc::new(Equal::new(
arc.start_angle,
target_start,
1.0,
)));
sys.add_constraint(Rc::new(Equal::new(
arc.end_angle,
target_end,
1.0,
)));
let target = sys.add_param(radius, true);
sys.add_constraint(Rc::new(Equal::new(arc.circle.rad, target, 1.0)));
}
EntityGeom::Ellipse(ellipse) => {
let (focus_distance, minor_radius) = {
+1 -1
View File
@@ -85,7 +85,7 @@ fn strip_option_listing(s: &str) -> String {
}
// Font swaps must preserve U+276F, U+24D8, and U+2715.
const COMMAND_PREFIX: &str = "❯ ";
const COMMAND_PREFIX: &str = "❯ ";
const INFO_PREFIX: &str = "ⓘ ";
const ERROR_PREFIX: &str = "✕ ";