← Commit history

1.0.9: 1.0.9: menu commands by label prefer an exact label over a longer one that contains it (Zoom to Selection no longer fires the Zoom to Selection Area tool, which parked the editor and made the API report busy)

John Lauer ·9d76738906 ·1mo ago ·parent 7c3f375
3 files changed +13−6
rust/Cargo.lock+3−3
@@ -244,7 +244,7 @@ dependencies = [  [[package]] name = "kicad-bridge"-version = "1.0.8"+version = "1.0.9" dependencies = [  "kicad-core",  "kicad-platform",@@ -255,7 +255,7 @@ dependencies = [  [[package]] name = "kicad-core"-version = "1.0.8"+version = "1.0.9" dependencies = [  "kicad-ipc-rs",  "kicad-platform",@@ -281,7 +281,7 @@ dependencies = [  [[package]] name = "kicad-platform"-version = "1.0.8"+version = "1.0.9" dependencies = [  "serde",  "serde_json",
rust/Cargo.toml+1−1
@@ -3,7 +3,7 @@ resolver = "2" members = ["crates/*"]  [workspace.package]-version = "1.0.8"+version = "1.0.9" edition = "2021" license = "MIT" publish = false
rust/crates/kicad-bridge/src/verbs_windows.rs+9−2
@@ -939,10 +939,17 @@ pub fn dialog_rows() -> Vec<bridge_log::DialogRow> { fn menu_invoke_by_text(hwnd: u64, needle: &str) -> Result<Option<(u32, String)>, String> {     let items = native().menu_tree(hwnd)?;     let want = needle.to_lowercase();+    // an exact label wins over a longer one that contains it: "Zoom to Selection" must never+    // fire "Zoom to Selection Area" (an interactive tool that parks the editor waiting for a drag)+    let clean = |l: &str| l.replace('&', "").split('\t').next().unwrap_or("").trim().to_lowercase();+    if let Some(it) = items.iter().find(|it| it.id != 0 && it.path.last().map(|l| clean(l) == want).unwrap_or(false)) {+        native().menu_invoke(hwnd, it.id)?;+        invalidate();+        return Ok(Some((it.id, it.path.last().unwrap().replace('&', ""))));+    }     for it in items {         let Some(label) = it.path.last() else { continue };-        let low = label.replace('&', "").to_lowercase();-        if low.contains(&want) && it.id != 0 {+        if clean(label).contains(&want) && it.id != 0 {             native().menu_invoke(hwnd, it.id)?;             invalidate();             return Ok(Some((it.id, label.replace('&', ""))));