From b27e1ec5c7c263e6448ae7b8d0e4fd7ba0368727 Mon Sep 17 00:00:00 2001 From: Junkui Zhang <364772080@qq.com> Date: Tue, 26 Aug 2025 00:21:22 +0800 Subject: [PATCH] fix --- crates/gpui/src/keymap/binding.rs | 32 +++++++++--------------------- crates/settings/src/keymap_file.rs | 12 ----------- 2 files changed, 9 insertions(+), 35 deletions(-) diff --git a/crates/gpui/src/keymap/binding.rs b/crates/gpui/src/keymap/binding.rs index edc772b4e9..a7cf9d5c54 100644 --- a/crates/gpui/src/keymap/binding.rs +++ b/crates/gpui/src/keymap/binding.rs @@ -1,7 +1,5 @@ use std::rc::Rc; -use collections::HashMap; - use crate::{ Action, AsKeystroke, DummyKeyboardMapper, InvalidKeystrokeError, KeyBindingContextPredicate, KeybindingKeystroke, Keystroke, PlatformKeyboardMapper, SharedString, @@ -41,7 +39,6 @@ impl KeyBinding { context_predicate, false, None, - None, &DummyKeyboardMapper, ) .unwrap() @@ -53,31 +50,20 @@ impl KeyBinding { action: Box, context_predicate: Option>, use_key_equivalents: bool, - key_equivalents: Option<&HashMap>, action_input: Option, keyboard_mapper: &dyn PlatformKeyboardMapper, ) -> std::result::Result { - let mut keystrokes: SmallVec<[Keystroke; 2]> = keystrokes + let keystrokes: SmallVec<[KeybindingKeystroke; 2]> = keystrokes .split_whitespace() - .map(Keystroke::parse) - .collect::>()?; - - if let Some(equivalents) = key_equivalents { - for keystroke in keystrokes.iter_mut() { - if keystroke.key.chars().count() == 1 - && let Some(key) = equivalents.get(&keystroke.key.chars().next().unwrap()) - { - keystroke.key = key.to_string(); - } - } - } - - let keystrokes = keystrokes - .into_iter() - .map(|keystroke| { - KeybindingKeystroke::new(keystroke, use_key_equivalents, keyboard_mapper) + .map(|source| { + let keystroke = Keystroke::parse(source)?; + Ok(KeybindingKeystroke::new( + keystroke, + use_key_equivalents, + keyboard_mapper, + )) }) - .collect(); + .collect::>()?; Ok(Self { keystrokes, diff --git a/crates/settings/src/keymap_file.rs b/crates/settings/src/keymap_file.rs index d9ae52d1cc..698c9315ce 100644 --- a/crates/settings/src/keymap_file.rs +++ b/crates/settings/src/keymap_file.rs @@ -212,9 +212,6 @@ impl KeymapFile { } pub fn load(content: &str, cx: &App) -> KeymapFileLoadResult { - let key_equivalents = - crate::key_equivalents::get_key_equivalents(cx.keyboard_layout().id()); - if content.is_empty() { return KeymapFileLoadResult::Success { key_bindings: Vec::new(), @@ -256,12 +253,6 @@ impl KeymapFile { } }; - let key_equivalents = if *use_key_equivalents { - key_equivalents.as_ref() - } else { - None - }; - let mut section_errors = String::new(); if !unrecognized_fields.is_empty() { @@ -280,7 +271,6 @@ impl KeymapFile { action, context_predicate.clone(), *use_key_equivalents, - key_equivalents, cx, ); match result { @@ -339,7 +329,6 @@ impl KeymapFile { action: &KeymapAction, context: Option>, use_key_equivalents: bool, - key_equivalents: Option<&HashMap>, cx: &App, ) -> std::result::Result { let (build_result, action_input_string) = match &action.0 { @@ -408,7 +397,6 @@ impl KeymapFile { action, context, use_key_equivalents, - key_equivalents, action_input_string.map(SharedString::from), cx.keyboard_mapper(), ) {