working perfectly well

This commit is contained in:
filipriec
2025-02-28 11:45:45 +01:00
parent f3ae029259
commit 2c43f22df6
3 changed files with 28 additions and 13 deletions

View File

@@ -21,7 +21,7 @@ move_word_end_prev = ["ge"] # Move to end of previous word
move_line_start = ["0"] # Move to beginning of line
move_line_end = ["$"] # Move to end of line
move_first_line = ["gg"] # Move to first line of form
move_last_line = ["x"]
move_last_line = ["g+enter"]
[colors]
theme = "dark"

View File

@@ -46,11 +46,6 @@ impl Config {
continue;
}
for binding in bindings {
// Skip multi-key bindings when checking for single key actions
if binding.len() > 1 && !binding.contains('+') {
continue;
}
if Self::matches_keybinding(binding, key, modifiers) {
return Some(action);
}
@@ -102,7 +97,15 @@ impl Config {
) -> bool {
// For multi-character bindings without modifiers, we handle them in matches_key_sequence
if binding.len() > 1 && !binding.contains('+') {
return false;
return match binding.to_lowercase().as_str() {
"left" => key == KeyCode::Left,
"right" => key == KeyCode::Right,
"up" => key == KeyCode::Up,
"down" => key == KeyCode::Down,
"esc" => key == KeyCode::Esc,
"enter" => key == KeyCode::Enter,
_ => false,
};
}
let parts: Vec<&str> = binding.split('+').collect();
@@ -114,13 +117,19 @@ impl Config {
"ctrl" => expected_modifiers |= KeyModifiers::CONTROL,
"shift" => expected_modifiers |= KeyModifiers::SHIFT,
"alt" => expected_modifiers |= KeyModifiers::ALT,
"left" => expected_key = Some(KeyCode::Left),
"right" => expected_key = Some(KeyCode::Right),
"up" => expected_key = Some(KeyCode::Up),
"down" => expected_key = Some(KeyCode::Down),
"esc" => expected_key = Some(KeyCode::Esc),
"enter" => expected_key = Some(KeyCode::Enter),
":" => expected_key = Some(KeyCode::Char(':')),
part if part.len() == 1 => {
let c = part.chars().next().unwrap();
expected_key = Some(KeyCode::Char(c));
part => {
if part.len() == 1 {
let c = part.chars().next().unwrap();
expected_key = Some(KeyCode::Char(c));
}
}
_ => (),
}
}

View File

@@ -48,6 +48,12 @@ impl KeySequenceTracker {
pub fn sequence_to_string(&self) -> String {
self.current_sequence.iter().map(|k| match k {
KeyCode::Char(c) => c.to_string(),
KeyCode::Left => "Left".into(),
KeyCode::Right => "Right".into(),
KeyCode::Up => "Up".into(),
KeyCode::Down => "Down".into(),
KeyCode::Esc => "Esc".into(),
KeyCode::Enter => "Enter".into(),
_ => String::new(),
}).collect()
}
@@ -95,10 +101,10 @@ fn parse_key_part(part: &str) -> Option<ParsedKey> {
"shift" => modifiers |= KeyModifiers::SHIFT,
"alt" => modifiers |= KeyModifiers::ALT,
"esc" => code = Some(KeyCode::Esc),
"up" => code = Some(KeyCode::Up),
"down" => code = Some(KeyCode::Down),
"left" => code = Some(KeyCode::Left),
"right" => code = Some(KeyCode::Right),
"up" => code = Some(KeyCode::Up),
"down" => code = Some(KeyCode::Down),
"enter" => code = Some(KeyCode::Enter),
"backspace" => code = Some(KeyCode::Backspace),
"delete" => code = Some(KeyCode::Delete),