aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorA-Walrus2022-08-30 01:58:51 +0000
committerGitHub2022-08-30 01:58:51 +0000
commitae81fbdbf6e44cc6b2aa35876afab65055e40df5 (patch)
tree1b01696b3010e2fb2e11dde0b46af88ad650bd72
parent841766ef828870651ac980860a317369bd110cd9 (diff)
Allow less than and greater than in macros (#3556)
* Allow less than and greater than in macros * Fix failing test
-rw-r--r--helix-view/src/input.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/helix-view/src/input.rs b/helix-view/src/input.rs
index 9fa679df..a7f526ba 100644
--- a/helix-view/src/input.rs
+++ b/helix-view/src/input.rs
@@ -116,6 +116,8 @@ pub(crate) mod keys {
pub(crate) const ESC: &str = "esc";
pub(crate) const SPACE: &str = "space";
pub(crate) const MINUS: &str = "minus";
+ pub(crate) const LESS_THAN: &str = "lt";
+ pub(crate) const GREATER_THAN: &str = "gt";
}
impl fmt::Display for KeyEvent {
@@ -156,6 +158,8 @@ impl fmt::Display for KeyEvent {
KeyCode::Esc => f.write_str(keys::ESC)?,
KeyCode::Char(' ') => f.write_str(keys::SPACE)?,
KeyCode::Char('-') => f.write_str(keys::MINUS)?,
+ KeyCode::Char('<') => f.write_str(keys::LESS_THAN)?,
+ KeyCode::Char('>') => f.write_str(keys::GREATER_THAN)?,
KeyCode::F(i) => f.write_fmt(format_args!("F{}", i))?,
KeyCode::Char(c) => f.write_fmt(format_args!("{}", c))?,
};
@@ -228,6 +232,8 @@ impl std::str::FromStr for KeyEvent {
keys::ESC => KeyCode::Esc,
keys::SPACE => KeyCode::Char(' '),
keys::MINUS => KeyCode::Char('-'),
+ keys::LESS_THAN => KeyCode::Char('<'),
+ keys::GREATER_THAN => KeyCode::Char('>'),
single if single.chars().count() == 1 => KeyCode::Char(single.chars().next().unwrap()),
function if function.len() > 1 && function.starts_with('F') => {
let function: String = function.chars().skip(1).collect();
@@ -548,8 +554,6 @@ mod test {
#[test]
fn parsing_unsupported_named_keys() {
- assert!(str::parse::<KeyEvent>("lt").is_err());
- assert!(str::parse::<KeyEvent>("gt").is_err());
assert!(str::parse::<KeyEvent>("plus").is_err());
assert!(str::parse::<KeyEvent>("percent").is_err());
assert!(str::parse::<KeyEvent>("semicolon").is_err());