Skip to content

Commit

Permalink
fix: shift-tab mappings broken after efc2b4c
Browse files Browse the repository at this point in the history
  • Loading branch information
archseer committed Nov 12, 2021
1 parent fa0cb01 commit d3def16
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
16 changes: 16 additions & 0 deletions helix-term/src/keymap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,22 @@ macro_rules! key {
};
}

#[macro_export]
macro_rules! shift {
($key:ident) => {
::helix_view::input::KeyEvent {
code: ::helix_view::keyboard::KeyCode::$key,
modifiers: ::helix_view::keyboard::KeyModifiers::SHIFT,
}
};
($($ch:tt)*) => {
::helix_view::input::KeyEvent {
code: ::helix_view::keyboard::KeyCode::Char($($ch)*),
modifiers: ::helix_view::keyboard::KeyModifiers::SHIFT,
}
};
}

#[macro_export]
macro_rules! ctrl {
($key:ident) => {
Expand Down
4 changes: 2 additions & 2 deletions helix-term/src/ui/menu.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
compositor::{Component, Compositor, Context, EventResult},
ctrl, key,
ctrl, key, shift,
};
use crossterm::event::Event;
use tui::{buffer::Buffer as Surface, widgets::Table};
Expand Down Expand Up @@ -202,7 +202,7 @@ impl<T: Item + 'static> Component for Menu<T> {
return close_fn;
}
// arrow up/ctrl-p/shift-tab prev completion choice (including updating the doc)
key!(BackTab) | key!(Up) | ctrl!('p') | ctrl!('k') => {
shift!(BackTab) | key!(Up) | ctrl!('p') | ctrl!('k') => {
self.move_up();
(self.callback_fn)(cx.editor, self.selection(), MenuEvent::Update);
return EventResult::Consumed(None);
Expand Down
4 changes: 2 additions & 2 deletions helix-term/src/ui/picker.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
compositor::{Component, Compositor, Context, EventResult},
ctrl, key,
ctrl, key, shift,
ui::EditorView,
};
use crossterm::event::Event;
Expand Down Expand Up @@ -404,7 +404,7 @@ impl<T: 'static> Component for Picker<T> {
})));

match key_event.into() {
key!(BackTab) | key!(Up) | ctrl!('p') | ctrl!('k') => {
shift!(BackTab) | key!(Up) | ctrl!('p') | ctrl!('k') => {
self.move_up();
}
key!(Tab) | key!(Down) | ctrl!('n') | ctrl!('j') => {
Expand Down
4 changes: 2 additions & 2 deletions helix-term/src/ui/prompt.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::compositor::{Component, Compositor, Context, EventResult};
use crate::{alt, ctrl, key, ui};
use crate::{alt, ctrl, key, shift, ui};
use crossterm::event::Event;
use helix_view::input::KeyEvent;
use helix_view::keyboard::{KeyCode, KeyModifiers};
Expand Down Expand Up @@ -496,7 +496,7 @@ impl Component for Prompt {
self.change_completion_selection(CompletionDirection::Forward);
(self.callback_fn)(cx, &self.line, PromptEvent::Update)
}
key!(BackTab) => {
shift!(BackTab) => {
self.change_completion_selection(CompletionDirection::Backward);
(self.callback_fn)(cx, &self.line, PromptEvent::Update)
}
Expand Down

0 comments on commit d3def16

Please sign in to comment.