From 94b5e0c2100d2d4e964120bf90dd8aebfd92eb27 Mon Sep 17 00:00:00 2001 From: Evgeniy Tatarkin Date: Mon, 6 Jan 2025 13:26:29 +0300 Subject: [PATCH] clippy --- helix-view/src/input.rs | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/helix-view/src/input.rs b/helix-view/src/input.rs index 0f824f2ed..29d00c1b3 100644 --- a/helix-view/src/input.rs +++ b/helix-view/src/input.rs @@ -338,23 +338,21 @@ impl std::str::FromStr for KeyEvent { KeyCode::from_str(tokens.pop().ok_or_else(|| anyhow!("Missing key code"))?) { code - } else { - if s.ends_with('-') && tokens.last().is_some_and(|t| t.is_empty()) { - if s == "-" { - return Ok(KeyEvent { - code: KeyCode::Char('-'), - modifiers: KeyModifiers::empty(), - }); - } else { - let suggestion = format!("{}-{}", s.trim_end_matches('-'), keys::MINUS); - anyhow::bail!( - "Key '-' cannot be used with modifiers, use '{}' instead", - suggestion - ) - } + } else if s.ends_with('-') && tokens.last().is_some_and(|t| t.is_empty()) { + if s == "-" { + return Ok(KeyEvent { + code: KeyCode::Char('-'), + modifiers: KeyModifiers::empty(), + }); } else { - anyhow::bail!("Invalid key code '{}'", s) + let suggestion = format!("{}-{}", s.trim_end_matches('-'), keys::MINUS); + anyhow::bail!( + "Key '-' cannot be used with modifiers, use '{}' instead", + suggestion + ) } + } else { + anyhow::bail!("Invalid key code '{}'", s) }; let mut modifiers = KeyModifiers::empty(); for token in tokens {