From 7e35a9e69ee3a86632cc7fda3729e8180c01db8b Mon Sep 17 00:00:00 2001 From: Omnikar Date: Wed, 8 Dec 2021 05:54:14 -0500 Subject: [PATCH] Special-case shift-tab -> backtab in `KeyEvent` conversion --- helix-view/src/input.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/helix-view/src/input.rs b/helix-view/src/input.rs index fe1067d29d5cf..e20b0e35f14b4 100644 --- a/helix-view/src/input.rs +++ b/helix-view/src/input.rs @@ -237,9 +237,18 @@ impl From for KeyEvent { #[cfg(feature = "term")] impl From for crossterm::event::KeyEvent { fn from(KeyEvent { code, modifiers }: KeyEvent) -> Self { - crossterm::event::KeyEvent { - code: code.into(), - modifiers: modifiers.into(), + if code == KeyCode::Tab && modifiers.contains(KeyModifiers::SHIFT) { + let mut modifiers = modifiers; + modifiers.remove(KeyModifiers::SHIFT); + crossterm::event::KeyEvent { + code: crossterm::event::KeyCode::BackTab, + modifiers: modifiers.into(), + } + } else { + crossterm::event::KeyEvent { + code: code.into(), + modifiers: modifiers.into(), + } } } }