diff options
Diffstat (limited to 'src/keys')
-rw-r--r-- | src/keys/key_config.rs | 12 | ||||
-rw-r--r-- | src/keys/key_list.rs | 25 |
2 files changed, 24 insertions, 13 deletions
diff --git a/src/keys/key_config.rs b/src/keys/key_config.rs index e48db11b..5feb5606 100644 --- a/src/keys/key_config.rs +++ b/src/keys/key_config.rs @@ -163,11 +163,11 @@ mod tests { NamedTempFile::new_in(&app_home).unwrap(); writeln!( temporary_key_list, - r" + r#" ( - move_down: Some(( code: Char('j'), modifiers: ( bits: 2,),)), + move_down: Some(( code: Char('j'), modifiers: "CONTROL")), ) -" +"# ) .unwrap(); @@ -175,11 +175,11 @@ mod tests { NamedTempFile::new_in(&app_home).unwrap(); writeln!( temporary_key_symbols, - " + r#" ( - esc: Some(\"Esc\"), + esc: Some("Esc"), ) -" +"# ) .unwrap(); diff --git a/src/keys/key_list.rs b/src/keys/key_list.rs index 55307193..cc6fc99a 100644 --- a/src/keys/key_list.rs +++ b/src/keys/key_list.rs @@ -34,8 +34,8 @@ impl From<&GituiKeyEvent> for KeyEvent { } } -#[derive(Clone, Patch)] -#[patch_derive(Deserialize)] +#[derive(Debug, Clone, Patch)] +#[patch_derive(Deserialize, Debug)] pub struct KeysList { pub tab_status: GituiKeyEvent, pub tab_log: GituiKeyEvent, @@ -217,8 +217,11 @@ impl KeysList { pub fn init(file: PathBuf) -> Self { let mut keys_list = Self::default(); if let Ok(f) = File::open(file) { - if let Ok(patch) = ron::de::from_reader(f) { - keys_list.apply(patch); + match ron::de::from_reader(f) { + Ok(patch) => keys_list.apply(patch), + Err(e) => { + log::error!("KeysList parse error: {e}"); + } } } keys_list @@ -248,11 +251,12 @@ mod tests { writeln!( file, - r" + r#" ( - move_down: Some(( code: Char('j'), modifiers: ( bits: 2,),)), + move_down: Some(( code: Char('j'), modifiers: "CONTROL")), + move_up: Some((code: Char('h'), modifiers: "")) ) -" +"# ) .unwrap(); @@ -266,5 +270,12 @@ mod tests { KeyModifiers::CONTROL ) ); + assert_eq!( + keys.move_up, + GituiKeyEvent::new( + KeyCode::Char('h'), + KeyModifiers::NONE + ) + ); } } |