From 2c43f22df6c362929432333d84d5e9b89ef6fc1e Mon Sep 17 00:00:00 2001 From: filipriec Date: Fri, 28 Feb 2025 11:45:45 +0100 Subject: [PATCH] working perfectly well --- client/config.toml | 2 +- client/src/config/config.rs | 29 +++++++++++++++++++---------- client/src/config/key_sequences.rs | 10 ++++++++-- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/client/config.toml b/client/config.toml index ee41e7f..1319cb1 100644 --- a/client/config.toml +++ b/client/config.toml @@ -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" diff --git a/client/src/config/config.rs b/client/src/config/config.rs index 3be0647..d596dcd 100644 --- a/client/src/config/config.rs +++ b/client/src/config/config.rs @@ -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)); + } } - _ => (), } } diff --git a/client/src/config/key_sequences.rs b/client/src/config/key_sequences.rs index 6cd33b9..7e5567b 100644 --- a/client/src/config/key_sequences.rs +++ b/client/src/config/key_sequences.rs @@ -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 { "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),