fix
This commit is contained in:
parent
11bc6586d8
commit
b27e1ec5c7
2 changed files with 9 additions and 35 deletions
|
@ -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<dyn Action>,
|
||||
context_predicate: Option<Rc<KeyBindingContextPredicate>>,
|
||||
use_key_equivalents: bool,
|
||||
key_equivalents: Option<&HashMap<char, char>>,
|
||||
action_input: Option<SharedString>,
|
||||
keyboard_mapper: &dyn PlatformKeyboardMapper,
|
||||
) -> std::result::Result<Self, InvalidKeystrokeError> {
|
||||
let mut keystrokes: SmallVec<[Keystroke; 2]> = keystrokes
|
||||
let keystrokes: SmallVec<[KeybindingKeystroke; 2]> = keystrokes
|
||||
.split_whitespace()
|
||||
.map(Keystroke::parse)
|
||||
.collect::<std::result::Result<_, _>>()?;
|
||||
|
||||
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::<std::result::Result<_, _>>()?;
|
||||
|
||||
Ok(Self {
|
||||
keystrokes,
|
||||
|
|
|
@ -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<Rc<KeyBindingContextPredicate>>,
|
||||
use_key_equivalents: bool,
|
||||
key_equivalents: Option<&HashMap<char, char>>,
|
||||
cx: &App,
|
||||
) -> std::result::Result<KeyBinding, String> {
|
||||
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(),
|
||||
) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue