diff --git a/Cargo.lock b/Cargo.lock index 92cec5d4e10d708c33d8da67fcc452ba7369e9e3..f2da762c83ace5223d69d941ddeb14d859f693a9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14566,6 +14566,7 @@ dependencies = [ name = "settings_ui" version = "0.1.0" dependencies = [ + "collections", "command_palette", "command_palette_hooks", "component", diff --git a/crates/settings_ui/Cargo.toml b/crates/settings_ui/Cargo.toml index 591dd8acaa99932112c9e78c2d81d7f4c6168cb1..7b01fcc0e6599dfd619d246a5a0a446e9bed4135 100644 --- a/crates/settings_ui/Cargo.toml +++ b/crates/settings_ui/Cargo.toml @@ -15,6 +15,7 @@ path = "src/settings_ui.rs" command_palette.workspace = true command_palette_hooks.workspace = true component.workspace = true +collections.workspace = true db.workspace = true editor.workspace = true feature_flags.workspace = true diff --git a/crates/settings_ui/src/keybindings.rs b/crates/settings_ui/src/keybindings.rs index ef17e6fadbe66f6c65798a1ce27735f62fa6cf7b..dc22de46b58dcbfaaaa20979eabcbbd546dea439 100644 --- a/crates/settings_ui/src/keybindings.rs +++ b/crates/settings_ui/src/keybindings.rs @@ -1,5 +1,6 @@ use std::{fmt::Write as _, ops::Range, sync::Arc}; +use collections::HashSet; use db::anyhow::anyhow; use editor::{Editor, EditorEvent}; use fuzzy::{StringMatch, StringMatchCandidate}; @@ -152,6 +153,7 @@ impl KeymapEditor { let key_bindings_ptr = cx.key_bindings(); let lock = key_bindings_ptr.borrow(); let key_bindings = lock.bindings(); + let mut unmapped_action_names = HashSet::from_iter(cx.all_action_names()); let mut processed_bindings = Vec::new(); let mut string_match_candidates = Vec::new(); @@ -173,6 +175,7 @@ impl KeymapEditor { .map(|meta| settings::KeybindSource::from_meta(meta).name().into()); let action_name = key_binding.action().name(); + unmapped_action_names.remove(&action_name); let index = processed_bindings.len(); let string_match_candidate = StringMatchCandidate::new(index, &action_name); @@ -185,6 +188,21 @@ impl KeymapEditor { }); string_match_candidates.push(string_match_candidate); } + + let empty = SharedString::new_static(""); + for action_name in unmapped_action_names.into_iter() { + let index = processed_bindings.len(); + let string_match_candidate = StringMatchCandidate::new(index, &action_name); + processed_bindings.push(ProcessedKeybinding { + keystroke_text: empty.clone(), + action: (*action_name).into(), + action_input: None, + context: empty.clone(), + source: None, + }); + string_match_candidates.push(string_match_candidate); + } + (processed_bindings, string_match_candidates) }