diff --git a/src/config.rs b/src/config.rs index 586a905..f17fef7 100644 --- a/src/config.rs +++ b/src/config.rs @@ -80,6 +80,7 @@ fn parse_keybind( key_to_evdev_key: &HashMap<&str, evdev::Key>, mod_to_mod_enum: &HashMap<&str, Modifier>, ) -> Result<(evdev::Key, Vec), Error> { + let line = line.split('#').next().unwrap(); let tokens: Vec = line.split('+').map(|s| s.trim().to_lowercase()).collect(); let last_token = tokens.last().unwrap().trim(); @@ -860,6 +861,28 @@ B ) } + #[test] + fn test_inline_comment() -> std::io::Result<()> { + let contents = " +super + a #comment and comment super + st +super + shift + b + ts #this comment should be handled by shell +" + .to_string(); + eval_config_test( + &contents, + vec![ + Hotkey::new(evdev::Key::KEY_A, vec![Modifier::Super], "st".to_string()), + Hotkey::new( + evdev::Key::KEY_B, + vec![Modifier::Super, Modifier::Shift], + "ts #this comment should be handled by shell".to_string(), + ), + ], + ) + } + #[test] #[ignore] fn test_numrow_special_keys() -> std::io::Result<()> {