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

+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);