on master help sign in
fix: shift-tab mappings broken after efc2b4c7
commitd3def16584f7f35a64ab2bad578436bd13cc18b6 authorBlaž Hrastnik <blaz@mxxn.io> dateFri 12 Nov 2021, 16:21 (5 years ago) parentfa0cb01
4 files changed+22−6
helix-term/src/keymap.rs+16 helix-term/src/ui/menu.rs+2−2 helix-term/src/ui/picker.rs+2−2 helix-term/src/ui/prompt.rs+2−2
helix-term/src/keymap.rs+16
@@ -25,6 +25,22 @@ macro_rules! key {
2525 };
2626}
2727
28+#[macro_export]
29+macro_rules! shift {
30+ ($key:ident) => {
31+ ::helix_view::input::KeyEvent {
32+ code: ::helix_view::keyboard::KeyCode::$key,
33+ modifiers: ::helix_view::keyboard::KeyModifiers::SHIFT,
34+ }
35+ };
36+ ($($ch:tt)*) => {
37+ ::helix_view::input::KeyEvent {
38+ code: ::helix_view::keyboard::KeyCode::Char($($ch)*),
39+ modifiers: ::helix_view::keyboard::KeyModifiers::SHIFT,
40+ }
41+ };
42+}
43+
2844#[macro_export]
2945macro_rules! ctrl {
3046 ($key:ident) => {
helix-term/src/ui/menu.rs+2−2
@@ -1,6 +1,6 @@
11use crate::{
22 compositor::{Component, Compositor, Context, EventResult},
3− ctrl, key,
3+ ctrl, key, shift,
44};
55use crossterm::event::Event;
66use tui::{buffer::Buffer as Surface, widgets::Table};
@@ -202,7 +202,7 @@ impl<T: Item + 'static> Component for Menu<T> {
202202 return close_fn;
203203 }
204204 // arrow up/ctrl-p/shift-tab prev completion choice (including updating the doc)
205− key!(BackTab) | key!(Up) | ctrl!('p') | ctrl!('k') => {
205+ shift!(BackTab) | key!(Up) | ctrl!('p') | ctrl!('k') => {
206206 self.move_up();
207207 (self.callback_fn)(cx.editor, self.selection(), MenuEvent::Update);
208208 return EventResult::Consumed(None);
helix-term/src/ui/picker.rs+2−2
@@ -1,6 +1,6 @@
11use crate::{
22 compositor::{Component, Compositor, Context, EventResult},
3− ctrl, key,
3+ ctrl, key, shift,
44 ui::EditorView,
55};
66use crossterm::event::Event;
@@ -404,7 +404,7 @@ impl<T: 'static> Component for Picker<T> {
404404 })));
405405
406406 match key_event.into() {
407− key!(BackTab) | key!(Up) | ctrl!('p') | ctrl!('k') => {
407+ shift!(BackTab) | key!(Up) | ctrl!('p') | ctrl!('k') => {
408408 self.move_up();
409409 }
410410 key!(Tab) | key!(Down) | ctrl!('n') | ctrl!('j') => {
helix-term/src/ui/prompt.rs+2−2
@@ -1,5 +1,5 @@
11use crate::compositor::{Component, Compositor, Context, EventResult};
2−use crate::{alt, ctrl, key, ui};
2+use crate::{alt, ctrl, key, shift, ui};
33use crossterm::event::Event;
44use helix_view::input::KeyEvent;
55use helix_view::keyboard::{KeyCode, KeyModifiers};
@@ -496,7 +496,7 @@ impl Component for Prompt {
496496 self.change_completion_selection(CompletionDirection::Forward);
497497 (self.callback_fn)(cx, &self.line, PromptEvent::Update)
498498 }
499− key!(BackTab) => {
499+ shift!(BackTab) => {
500500 self.change_completion_selection(CompletionDirection::Backward);
501501 (self.callback_fn)(cx, &self.line, PromptEvent::Update)
502502 }