From ffa08d3a3126ec74dfffb8df03538d2938cc4dcb Mon Sep 17 00:00:00 2001 From: aiongg Date: Sun, 25 Oct 2026 03:52:28 +0000 Subject: [PATCH] Batch: Circular References submenu quotes sheet names that need quotes (#2501) --- crates/ui-egui/src/ribbon.rs | 2 +- crates/ui-egui/tests/it/error_checking_menu.rs | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/crates/ui-egui/src/ribbon.rs b/crates/ui-egui/src/ribbon.rs index 8bbaa1f48..9298fd10e 100644 --- a/crates/ui-egui/src/ribbon.rs +++ b/crates/ui-egui/src/ribbon.rs @@ -480,7 +480,7 @@ fn circular_references(app: &SheetApp) -> Vec<(usize, String, String)> { .circular .iter() .filter(|k| seen.insert(**k)) - .filter_map(|(si, c)| d.wb.sheet(*si).map(|sh| (*si, c.a1(), format!("{}!{}", sh.name, c.a1())))) + .filter_map(|(si, c)| d.wb.sheet(*si).map(|sh| (*si, c.a1(), format!("{}!{}", gridcraft_engine::formula::quote_sheet(&sh.name), c.a1())))) .take(CIRCULAR_MENU_LIMIT) .collect() } diff --git a/crates/ui-egui/tests/it/error_checking_menu.rs b/crates/ui-egui/tests/it/error_checking_menu.rs index 10467e163..e0e1e8e41 100644 --- a/crates/ui-egui/tests/it/error_checking_menu.rs +++ b/crates/ui-egui/tests/it/error_checking_menu.rs @@ -16,7 +16,7 @@ const CIRCULAR: &str = "Circular References ⏵"; fn harness(loops: bool) -> Harness { let mut s = Session::new(); s.new_workbook(); - s.execute("home.insertSheet", json!({"name": "Data"})).unwrap(); + s.execute("home.insertSheet", json!({"name": "Q1 Data"})).unwrap(); if loops { s.execute("cell.set", json!({"cell": "B3", "input": "=B4"})).unwrap(); s.execute("cell.set", json!({"cell": "B4", "input": "=B3"})).unwrap(); @@ -104,13 +104,14 @@ fn circular_references_lists_the_loops_and_selects_the_cell_picked() { assert!(!h.get_by_label(CIRCULAR).accesskit_node().is_disabled()); hover(&mut h, CIRCULAR); assert!(h.query_by_label("Sheet1!C2").is_some(), "the loop on the active sheet is listed"); - let other = ["Data!B3", "Data!B4"].into_iter().find(|l| h.query_by_label(l).is_some()).expect("the loop on Data is listed"); + // A sheet name with a space is quoted, as in a formula. + let other = ["'Q1 Data'!B3", "'Q1 Data'!B4"].into_iter().find(|l| h.query_by_label(l).is_some()).expect("the loop on Q1 Data is listed"); h.get_by_label(other).click(); h.run_steps(4); let app = h.state(); let d = app.session.active().unwrap(); - assert_eq!(d.wb.active_sheet, 1, "picking a cell on Data goes to Data"); - assert_eq!(format!("Data!{}", d.selection.active.a1()), other); + assert_eq!(d.wb.active_sheet, 1, "picking a cell on Q1 Data goes to Q1 Data"); + assert_eq!(format!("'Q1 Data'!{}", d.selection.active.a1()), other); } #[test]