From 919d74bee612a3de38f0d20948fa53d6da9c3ea0 Mon Sep 17 00:00:00 2001 From: Valentin Klein Date: Sat, 10 Oct 2026 15:27:11 +0200 Subject: [PATCH] Shift+F3 runs Change Case again, not Find Previous (#186) (#221) * Shift+F3 runs Change Case again, not Find Previous (#186) edit.findPrevious and format.changeCase were both bound to Shift+F3. Registry::by_shortcut returns the first match, so Find Previous won and Change Case never ran from the keyboard. Find Previous keeps Mod+Shift+G. A new test fails if any two commands share a shortcut. Co-Authored-By: Claude Opus 5.5 * Contributors: credit vangel76 by their GitHub profile name Co-Authored-By: Claude Opus 5.5 --------- Co-authored-by: Claude Opus 5.5 Co-authored-by: Brandon Thomas --- contributors/people.toml | 3 +++ crates/engine/src/cmd/edit.rs | 2 +- crates/engine/src/tests.rs | 15 +++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/contributors/people.toml b/contributors/people.toml index cdaacd59a5..bbb6dd8371 100644 --- a/contributors/people.toml +++ b/contributors/people.toml @@ -29,3 +29,6 @@ sync_github_name = false [people.saeedemperor] real_name = "Saeed Azarehgar" + +[people.vangel76] +sync_github_name = true diff --git a/crates/engine/src/cmd/edit.rs b/crates/engine/src/cmd/edit.rs index 3d31bb1ac2..1a86a758c0 100644 --- a/crates/engine/src/cmd/edit.rs +++ b/crates/engine/src/cmd/edit.rs @@ -37,7 +37,7 @@ pub fn specs() -> Vec { .params(r#"{"text": string, "matchCase"?: bool, "wholeWord"?: bool, "regex"?: bool}"#) .pure(), CommandSpec::new("edit.findNext", "Find Next", "Home › Editing › Find", |s, _| step(s, 1)).key("Mod+G / F3").pure(), - CommandSpec::new("edit.findPrevious", "Find Previous", "Home › Editing › Find", |s, _| step(s, -1)).key("Mod+Shift+G / Shift+F3").pure(), + CommandSpec::new("edit.findPrevious", "Find Previous", "Home › Editing › Find", |s, _| step(s, -1)).key("Mod+Shift+G").pure(), CommandSpec::new("edit.replace", "Replace", "Home › Editing", replace).key("Mod+H").params(r#"{"text": string, "with": string}"#), CommandSpec::new("edit.replaceAll", "Replace All", "Home › Editing › Replace", replace_all) .params(r#"{"text": string, "with": string, "matchCase"?: bool, "wholeWord"?: bool, "regex"?: bool}"#), diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index 81347e6768..13ea76dd22 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -36,6 +36,21 @@ fn every_command_has_unique_id() { assert!(n > 150, "{n} commands"); } +#[test] +fn every_shortcut_runs_one_command() { + // `by_shortcut` takes the first match, so a shared key silently shadows the later command (#186). + let reg = cmd::registry(); + let mut seen = std::collections::HashMap::new(); + for c in reg.all() { + for k in c.shortcut.split(" / ").filter(|k| !k.is_empty()) { + if let Some(other) = seen.insert(k.to_ascii_lowercase(), c.id) { + panic!("{k} is bound to both {other} and {}", c.id); + } + } + } + assert_eq!(reg.by_shortcut("Shift+F3").map(|c| c.id), Some("format.changeCase")); +} + #[test] fn typing_enter_undo() { let mut s = s();