fix(xref): follow-ups to the xref attach parity merge

- `XREF <args>` runs whole: probing the bare verb first now opens the
  External References palette, which refreshed every entry and toggled
  the palette before `XREF Reload A` / `XREF ?` ran.
- Update the two tests that encoded the old behaviour: `-XREF ?` prints
  the reference table, and attaching a missing file is rejected.
- Drop the duplicate "Specify On-screen" catalog entry that shadowed the
  translated common key, with its unused ftl keys.
- Move `remove_pipe_symbols`' doc comment back above its function.
- Note in `document_for_save` that resolved xref content stays out.
- Gate the desktop-only preview cap and tab index for wasm.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Hakan SevenandClaude Opus 5.5 committed 2026-09-24 15:37:00 +03:00
1 parent 1988424638
commit 163763c42a
27 files changed
+27 -35

No files matched your search

-1
View File
@@ -3513,7 +3513,6 @@ insert =
.xref-attach-dialog-title = Attach External Reference
.xref-attach-browse = Browse...
.xref-attach-reference-type = Reference Type
.xref-attach-specify-on-screen = Specify On-screen
.xref-attach-uniform-scale = Uniform Scale
.xref-attach-insertion-point = Insertion point
.xref-attach-angle = Angle:
-1
View File
@@ -3500,7 +3500,6 @@ insert =
.xref-attach-dialog-title = Attach External Reference
.xref-attach-browse = Browse...
.xref-attach-reference-type = Reference Type
.xref-attach-specify-on-screen = Specify On-screen
.xref-attach-uniform-scale = Uniform Scale
.xref-attach-insertion-point = Insertion point
.xref-attach-angle = Angle:
-1
View File
@@ -3498,7 +3498,6 @@ insert =
.xref-attach-dialog-title = Attach External Reference
.xref-attach-browse = Browse...
.xref-attach-reference-type = Reference Type
.xref-attach-specify-on-screen = Specify On-screen
.xref-attach-uniform-scale = Uniform Scale
.xref-attach-insertion-point = Insertion point
.xref-attach-angle = Angle:
-1
View File
@@ -3501,7 +3501,6 @@ insert =
.xref-attach-dialog-title = Attach External Reference
.xref-attach-browse = Browse...
.xref-attach-reference-type = Reference Type
.xref-attach-specify-on-screen = Specify On-screen
.xref-attach-uniform-scale = Uniform Scale
.xref-attach-insertion-point = Insertion point
.xref-attach-angle = Angle:
-1
View File
@@ -3501,7 +3501,6 @@ insert =
.xref-attach-dialog-title = Attach External Reference
.xref-attach-browse = Browse...
.xref-attach-reference-type = Reference Type
.xref-attach-specify-on-screen = Specify On-screen
.xref-attach-uniform-scale = Uniform Scale
.xref-attach-insertion-point = Insertion point
.xref-attach-angle = Angle:
-1
View File
@@ -3502,7 +3502,6 @@ insert =
.xref-attach-dialog-title = Attach External Reference
.xref-attach-browse = Browse...
.xref-attach-reference-type = Reference Type
.xref-attach-specify-on-screen = Specify On-screen
.xref-attach-uniform-scale = Uniform Scale
.xref-attach-insertion-point = Insertion point
.xref-attach-angle = Angle:
-1
View File
@@ -3501,7 +3501,6 @@ insert =
.xref-attach-dialog-title = Attach External Reference
.xref-attach-browse = Browse...
.xref-attach-reference-type = Reference Type
.xref-attach-specify-on-screen = Specify On-screen
.xref-attach-uniform-scale = Uniform Scale
.xref-attach-insertion-point = Insertion point
.xref-attach-angle = Angle:
-1
View File
@@ -3500,7 +3500,6 @@ insert =
.xref-attach-dialog-title = Attach External Reference
.xref-attach-browse = Browse...
.xref-attach-reference-type = Reference Type
.xref-attach-specify-on-screen = Specify On-screen
.xref-attach-uniform-scale = Uniform Scale
.xref-attach-insertion-point = Insertion point
.xref-attach-angle = Angle:
-1
View File
@@ -3501,7 +3501,6 @@ insert =
.xref-attach-dialog-title = Attach External Reference
.xref-attach-browse = Browse...
.xref-attach-reference-type = Reference Type
.xref-attach-specify-on-screen = Specify On-screen
.xref-attach-uniform-scale = Uniform Scale
.xref-attach-insertion-point = Insertion point
.xref-attach-angle = Angle:
-1
View File
@@ -3489,7 +3489,6 @@ insert =
.xref-attach-dialog-title = Attach External Reference
.xref-attach-browse = Browse...
.xref-attach-reference-type = Reference Type
.xref-attach-specify-on-screen = Specify On-screen
.xref-attach-uniform-scale = Uniform Scale
.xref-attach-insertion-point = Insertion point
.xref-attach-angle = Angle:
-1
View File
@@ -3500,7 +3500,6 @@ insert =
.xref-attach-dialog-title = Attach External Reference
.xref-attach-browse = Browse...
.xref-attach-reference-type = Reference Type
.xref-attach-specify-on-screen = Specify On-screen
.xref-attach-uniform-scale = Uniform Scale
.xref-attach-insertion-point = Insertion point
.xref-attach-angle = Angle:
-1
View File
@@ -3500,7 +3500,6 @@ insert =
.xref-attach-dialog-title = Attach External Reference
.xref-attach-browse = Browse...
.xref-attach-reference-type = Reference Type
.xref-attach-specify-on-screen = Specify On-screen
.xref-attach-uniform-scale = Uniform Scale
.xref-attach-insertion-point = Insertion point
.xref-attach-angle = Angle:
-1
View File
@@ -3491,7 +3491,6 @@ insert =
.xref-attach-dialog-title = Attach External Reference
.xref-attach-browse = Browse...
.xref-attach-reference-type = Reference Type
.xref-attach-specify-on-screen = Specify On-screen
.xref-attach-uniform-scale = Uniform Scale
.xref-attach-insertion-point = Insertion point
.xref-attach-angle = Angle:
-1
View File
@@ -3500,7 +3500,6 @@ insert =
.xref-attach-dialog-title = Attach External Reference
.xref-attach-browse = Browse...
.xref-attach-reference-type = Reference Type
.xref-attach-specify-on-screen = Specify On-screen
.xref-attach-uniform-scale = Uniform Scale
.xref-attach-insertion-point = Insertion point
.xref-attach-angle = Angle:
-1
View File
@@ -3499,7 +3499,6 @@ insert =
.xref-attach-dialog-title = Attach External Reference
.xref-attach-browse = Browse...
.xref-attach-reference-type = Reference Type
.xref-attach-specify-on-screen = Specify On-screen
.xref-attach-uniform-scale = Uniform Scale
.xref-attach-insertion-point = Insertion point
.xref-attach-angle = Angle:
-1
View File
@@ -3500,7 +3500,6 @@ insert =
.xref-attach-dialog-title = Attach External Reference
.xref-attach-browse = Browse...
.xref-attach-reference-type = Reference Type
.xref-attach-specify-on-screen = Specify On-screen
.xref-attach-uniform-scale = Uniform Scale
.xref-attach-insertion-point = Insertion point
.xref-attach-angle = Angle:
-1
View File
@@ -3501,7 +3501,6 @@ insert =
.xref-attach-dialog-title = Attach External Reference
.xref-attach-browse = Browse...
.xref-attach-reference-type = Reference Type
.xref-attach-specify-on-screen = Specify On-screen
.xref-attach-uniform-scale = Uniform Scale
.xref-attach-insertion-point = Insertion point
.xref-attach-angle = Angle:
-1
View File
@@ -3502,7 +3502,6 @@ insert =
.xref-attach-dialog-title = Attach External Reference
.xref-attach-browse = Browse...
.xref-attach-reference-type = Reference Type
.xref-attach-specify-on-screen = Specify On-screen
.xref-attach-uniform-scale = Uniform Scale
.xref-attach-insertion-point = Insertion point
.xref-attach-angle = Angle:
-1
View File
@@ -3475,7 +3475,6 @@ insert =
.xref-attach-dialog-title = Harici Referans Ekle
.xref-attach-browse = Gözat...
.xref-attach-reference-type = Referans Türü
.xref-attach-specify-on-screen = Ekranda belirt
.xref-attach-uniform-scale = Eşit ölçek
.xref-attach-insertion-point = Ekleme noktası
.xref-attach-angle = Açı:
-1
View File
@@ -3488,7 +3488,6 @@ insert =
.xref-attach-dialog-title = Attach External Reference
.xref-attach-browse = Browse...
.xref-attach-reference-type = Reference Type
.xref-attach-specify-on-screen = Specify On-screen
.xref-attach-uniform-scale = Uniform Scale
.xref-attach-insertion-point = Insertion point
.xref-attach-angle = Angle:
-1
View File
@@ -3500,7 +3500,6 @@ insert =
.xref-attach-dialog-title = Attach External Reference
.xref-attach-browse = Browse...
.xref-attach-reference-type = Reference Type
.xref-attach-specify-on-screen = Specify On-screen
.xref-attach-uniform-scale = Uniform Scale
.xref-attach-insertion-point = Insertion point
.xref-attach-angle = Angle:
+4
View File
@@ -711,8 +711,12 @@ impl OpenCADStudio {
let toks: Vec<String> = tokens.iter().map(|s| s.to_string()).collect();
return self.finish_active_command(&toks, finish);
}
// Bare XREF opens the External References palette, so probing the
// verb alone would open it (and refresh every entry) before the
// argument form `XREF Reload A` runs.
if tokens[0].eq_ignore_ascii_case("BACKGROUND")
|| tokens[0].eq_ignore_ascii_case("COLORSCHEME")
|| tokens[0].eq_ignore_ascii_case("XREF")
{
return self.dispatch_command(cmd);
}
+11 -5
View File
@@ -1598,11 +1598,11 @@ mod tests {
#[test]
fn xref_dash_alias_lists_like_xref() {
// `-XREF` is accepted as an alias for industry muscle memory; bare
// `XREF` keeps the legacy list output for compatibility.
// `-XREF` asks on the command line: `?` then Enter prints the
// reference table; `XREF ?` keeps the legacy list output for scripts.
let mut app = fresh_app();
let out = run_capture(&mut app, "-XREF ?");
assert!(out.contains("No external references") || out.contains("External references"));
assert!(out.contains("Total Xref(s): 0"), "got: {out:?}");
}
#[test]
@@ -2015,9 +2015,15 @@ mod tests {
#[test]
fn xref_attach_with_file_starts_placement() {
// F10: `XREF Attach <file>` threads the file into the XATTACH
// placement command (same flow as the picker result).
// placement command (same flow as the picker result). A missing file
// is rejected up front, so the reference has to exist.
let dir = std::env::temp_dir().join(format!("ocs_xref_attach_{}", std::process::id()));
std::fs::create_dir_all(&dir).unwrap();
let file = dir.join("plan.dwg");
std::fs::write(&file, b"fake").unwrap();
let mut app = fresh_app();
let out = run_capture(&mut app, "XREF Attach C:/refs/plan.dwg");
let out = run_capture(&mut app, &format!("XREF Attach {}", file.to_string_lossy()));
std::fs::remove_dir_all(&dir).ok();
assert!(
!out.contains("ships with reference operations"),
"dead-end text must be gone, got: {out:?}"
+2
View File
@@ -175,6 +175,7 @@ impl OpenCADStudio {
path: &str,
) -> (Vec<crate::scene::model::wire_model::WireModel>, i16) {
// ponytail: a huge reference skips the ghost; cap by entity count.
#[cfg(not(target_arch = "wasm32"))]
const MAX_PREVIEW_ENTITIES: usize = 20_000;
let scene = &self.tabs[i].scene;
if let Some(name) = existing {
@@ -264,6 +265,7 @@ impl OpenCADStudio {
/// Fills the dialog from the chosen file: name, preview, block unit and
/// the paths shown under Details.
fn load_xref_attach_file(&self, state: &mut XrefAttachState, path: &str) {
#[cfg(not(target_arch = "wasm32"))]
let i = self.active_tab;
state.path = path.to_string();
state.name = path_to_block_name(path);
+7 -7
View File
@@ -1857,13 +1857,6 @@ fn same_file(a: &Path, b: &Path) -> bool {
}
}
/// Remove one xref's `name|*` dependent symbols (case-insensitive): layers,
/// linetypes, text styles, dim styles, and nested block records — plus every
/// entity and draw-order table owned by those dependent blocks.
///
/// Shared by Detach (which then also erases the BlockRecord itself) and BIND
/// (which drops the previous merge before re-merging under `$N$` names). The
/// xref BlockRecord itself, its INSERTs, and non-prefixed symbols stay.
/// Make the named references' paths relative to `host` (their drawing's
/// first save); a reference that cannot be relative keeps its full path.
pub fn make_relative(
@@ -1922,6 +1915,13 @@ fn linetype_styles(doc: &CadDocument) -> HashSet<Handle> {
.collect()
}
/// Remove one xref's `name|*` dependent symbols (case-insensitive): layers,
/// linetypes, text styles, dim styles, and nested block records — plus every
/// entity and draw-order table owned by those dependent blocks.
///
/// Shared by Detach (which then also erases the BlockRecord itself) and BIND
/// (which drops the previous merge before re-merging under `$N$` names). The
/// xref BlockRecord itself, its INSERTs, and non-prefixed symbols stay.
fn remove_pipe_symbols(doc: &mut CadDocument, name: &str) {
remove_dependent_symbols(doc, name, true);
}
-1
View File
@@ -268,7 +268,6 @@ pub(super) fn message_attribute(source: &str) -> Option<(&'static str, &'static
"Attach External Reference" => Some(("insert", "xref-attach-dialog-title")),
"Browse..." => Some(("insert", "xref-attach-browse")),
"Reference Type" => Some(("insert", "xref-attach-reference-type")),
"Specify On-screen" => Some(("insert", "xref-attach-specify-on-screen")),
"Uniform Scale" => Some(("insert", "xref-attach-uniform-scale")),
"Insertion point" => Some(("insert", "xref-attach-insertion-point")),
"Angle:" => Some(("insert", "xref-attach-angle")),
+3 -1
View File
@@ -2507,7 +2507,9 @@ impl super::Scene {
}
/// The document as written to a file: a dynamic dimension's screen-size
/// overrides are a display matter and stay out of the file.
/// overrides are a display matter and stay out of the file, and so does
/// what resolving an external reference merged in (its geometry, nested
/// blocks and styles), which the file never stores.
pub(crate) fn document_for_save(&self) -> acadrust::CadDocument {
use crate::entities::dim_override as ov;
let mut document = self.document.clone();