on master help sign in
fix: Normalize backtab into shift-tab
cab0909Blaž Hrastnik
book/src/remapping.md+2−3
@@ -42,10 +42,9 @@ Control, Shift and Alt modifiers are encoded respectively with the prefixes
42| Down | `"down"` |
42| Down | `"down"` |
43| Home | `"home"` |
43| Home | `"home"` |
44| End | `"end"` |
44| End | `"end"` |
45−| Page | `"pageup"` |
45+| Page Up | `"pageup"` |
46−| Page | `"pagedown"` |
46+| Page Down | `"pagedown"` |
47| Tab | `"tab"` |
47| Tab | `"tab"` |
48−| Back | `"backtab"` |
49| Delete | `"del"` |
48| Delete | `"del"` |
50| Insert | `"ins"` |
49| Insert | `"ins"` |
51| Null | `"null"` |
50| Null | `"null"` |
helix-term/src/ui/menu.rs+1−1
@@ -202,7 +202,7 @@ impl<T: Item + 'static> Component for Menu<T> {
202 return close_fn;
202 return close_fn;
203 }
203 }
204 // arrow up/ctrl-p/shift-tab prev completion choice (including updating the doc)
204 // arrow up/ctrl-p/shift-tab prev completion choice (including updating the doc)
205− shift!(BackTab) | key!(Up) | ctrl!('p') | ctrl!('k') => {
205+ shift!(Tab) | key!(Up) | ctrl!('p') | ctrl!('k') => {
206 self.move_up();
206 self.move_up();
207 (self.callback_fn)(cx.editor, self.selection(), MenuEvent::Update);
207 (self.callback_fn)(cx.editor, self.selection(), MenuEvent::Update);
208 return EventResult::Consumed(None);
208 return EventResult::Consumed(None);
helix-term/src/ui/picker.rs+1−1
@@ -410,7 +410,7 @@ impl<T: 'static> Component for Picker<T> {
410 })));
410 })));
411
411
412 match key_event.into() {
412 match key_event.into() {
413− shift!(BackTab) | key!(Up) | ctrl!('p') | ctrl!('k') => {
413+ shift!(Tab) | key!(Up) | ctrl!('p') | ctrl!('k') => {
414 self.move_up();
414 self.move_up();
415 }
415 }
416 key!(Tab) | key!(Down) | ctrl!('n') | ctrl!('j') => {
416 key!(Tab) | key!(Down) | ctrl!('n') | ctrl!('j') => {
helix-term/src/ui/prompt.rs+1−1
@@ -505,7 +505,7 @@ impl Component for Prompt {
505 self.change_completion_selection(CompletionDirection::Forward);
505 self.change_completion_selection(CompletionDirection::Forward);
506 (self.callback_fn)(cx, &self.line, PromptEvent::Update)
506 (self.callback_fn)(cx, &self.line, PromptEvent::Update)
507 }
507 }
508− shift!(BackTab) => {
508+ shift!(Tab) => {
509 self.change_completion_selection(CompletionDirection::Backward);
509 self.change_completion_selection(CompletionDirection::Backward);
510 (self.callback_fn)(cx, &self.line, PromptEvent::Update)
510 (self.callback_fn)(cx, &self.line, PromptEvent::Update)
511 }
511 }
helix-view/src/input.rs+14−10
@@ -36,7 +36,6 @@ pub(crate) mod keys {
36 pub(crate) const PAGEUP: &str = "pageup";
36 pub(crate) const PAGEUP: &str = "pageup";
37 pub(crate) const PAGEDOWN: &str = "pagedown";
37 pub(crate) const PAGEDOWN: &str = "pagedown";
38 pub(crate) const TAB: &str = "tab";
38 pub(crate) const TAB: &str = "tab";
39− pub(crate) const BACKTAB: &str = "backtab";
40 pub(crate) const DELETE: &str = "del";
39 pub(crate) const DELETE: &str = "del";
41 pub(crate) const INSERT: &str = "ins";
40 pub(crate) const INSERT: &str = "ins";
42 pub(crate) const NULL: &str = "null";
41 pub(crate) const NULL: &str = "null";
@@ -82,7 +81,6 @@ impl fmt::Display for KeyEvent {
82 KeyCode::PageUp => f.write_str(keys::PAGEUP)?,
81 KeyCode::PageUp => f.write_str(keys::PAGEUP)?,
83 KeyCode::PageDown => f.write_str(keys::PAGEDOWN)?,
82 KeyCode::PageDown => f.write_str(keys::PAGEDOWN)?,
84 KeyCode::Tab => f.write_str(keys::TAB)?,
83 KeyCode::Tab => f.write_str(keys::TAB)?,
85− KeyCode::BackTab => f.write_str(keys::BACKTAB)?,
86 KeyCode::Delete => f.write_str(keys::DELETE)?,
84 KeyCode::Delete => f.write_str(keys::DELETE)?,
87 KeyCode::Insert => f.write_str(keys::INSERT)?,
85 KeyCode::Insert => f.write_str(keys::INSERT)?,
88 KeyCode::Null => f.write_str(keys::NULL)?,
86 KeyCode::Null => f.write_str(keys::NULL)?,
@@ -116,7 +114,6 @@ impl UnicodeWidthStr for KeyEvent {
116 KeyCode::PageUp => keys::PAGEUP.len(),
114 KeyCode::PageUp => keys::PAGEUP.len(),
117 KeyCode::PageDown => keys::PAGEDOWN.len(),
115 KeyCode::PageDown => keys::PAGEDOWN.len(),
118 KeyCode::Tab => keys::TAB.len(),
116 KeyCode::Tab => keys::TAB.len(),
119− KeyCode::BackTab => keys::BACKTAB.len(),
120 KeyCode::Delete => keys::DELETE.len(),
117 KeyCode::Delete => keys::DELETE.len(),
121 KeyCode::Insert => keys::INSERT.len(),
118 KeyCode::Insert => keys::INSERT.len(),
122 KeyCode::Null => keys::NULL.len(),
119 KeyCode::Null => keys::NULL.len(),
@@ -166,7 +163,6 @@ impl std::str::FromStr for KeyEvent {
166 keys::PAGEUP => KeyCode::PageUp,
163 keys::PAGEUP => KeyCode::PageUp,
167 keys::PAGEDOWN => KeyCode::PageDown,
164 keys::PAGEDOWN => KeyCode::PageDown,
168 keys::TAB => KeyCode::Tab,
165 keys::TAB => KeyCode::Tab,
169− keys::BACKTAB => KeyCode::BackTab,
170 keys::DELETE => KeyCode::Delete,
166 keys::DELETE => KeyCode::Delete,
171 keys::INSERT => KeyCode::Insert,
167 keys::INSERT => KeyCode::Insert,
172 keys::NULL => KeyCode::Null,
168 keys::NULL => KeyCode::Null,
@@ -220,12 +216,20 @@ impl<'de> Deserialize<'de> for KeyEvent {
220
216
221#[cfg(feature = "term")]
217#[cfg(feature = "term")]
222impl From<crossterm::event::KeyEvent> for KeyEvent {
218impl From<crossterm::event::KeyEvent> for KeyEvent {
223− fn from(
224− crossterm::event::KeyEvent { code, modifiers }: crossterm::event::KeyEvent,
219+ fn from(crossterm::event::KeyEvent { code, modifiers }: crossterm::event::KeyEvent) -> Self {
225− ) -> KeyEvent {
220+ if code == crossterm::event::KeyCode::BackTab {
226− KeyEvent {
221+ // special case for BackTab -> Shift-Tab
222+ let mut modifiers: KeyModifiers = modifiers.into();
223+ modifiers.insert(KeyModifiers::SHIFT);
224+ Self {
225+ code: KeyCode::Tab,
226+ modifiers,
227+ }
228+ } else {
229+ Self {
227− code: code.into(),
230+ code: code.into(),
228− modifiers: modifiers.into(),
231+ modifiers: modifiers.into(),
232+ }
229 }
233 }
230 }
234 }
231}
235}
helix-view/src/keyboard.rs+1−4
@@ -79,8 +79,6 @@ pub enum KeyCode {
79 PageDown,
79 PageDown,
80 /// Tab key.
80 /// Tab key.
81 Tab,
81 Tab,
82− /// Shift + Tab key.
83− BackTab,
84 /// Delete key.
82 /// Delete key.
85 Delete,
83 Delete,
86 /// Insert key.
84 /// Insert key.
@@ -116,7 +114,6 @@ impl From<KeyCode> for crossterm::event::KeyCode {
116 KeyCode::PageUp => CKeyCode::PageUp,
114 KeyCode::PageUp => CKeyCode::PageUp,
117 KeyCode::PageDown => CKeyCode::PageDown,
115 KeyCode::PageDown => CKeyCode::PageDown,
118 KeyCode::Tab => CKeyCode::Tab,
116 KeyCode::Tab => CKeyCode::Tab,
119− KeyCode::BackTab => CKeyCode::BackTab,
120 KeyCode::Delete => CKeyCode::Delete,
117 KeyCode::Delete => CKeyCode::Delete,
121 KeyCode::Insert => CKeyCode::Insert,
118 KeyCode::Insert => CKeyCode::Insert,
122 KeyCode::F(f_number) => CKeyCode::F(f_number),
119 KeyCode::F(f_number) => CKeyCode::F(f_number),
@@ -144,7 +141,7 @@ impl From<crossterm::event::KeyCode> for KeyCode {
144 CKeyCode::PageUp => KeyCode::PageUp,
141 CKeyCode::PageUp => KeyCode::PageUp,
145 CKeyCode::PageDown => KeyCode::PageDown,
142 CKeyCode::PageDown => KeyCode::PageDown,
146 CKeyCode::Tab => KeyCode::Tab,
143 CKeyCode::Tab => KeyCode::Tab,
147− CKeyCode::BackTab => KeyCode::BackTab,
144+ CKeyCode::BackTab => unreachable!("BackTab should have been handled on KeyEvent level"),
148 CKeyCode::Delete => KeyCode::Delete,
145 CKeyCode::Delete => KeyCode::Delete,
149 CKeyCode::Insert => KeyCode::Insert,
146 CKeyCode::Insert => KeyCode::Insert,
150 CKeyCode::F(f_number) => KeyCode::F(f_number),
147 CKeyCode::F(f_number) => KeyCode::F(f_number),