fix: shift-tab mappings broken after efc2b4c7

pull/1091/head
Blaž Hrastnik 3 years ago
parent fa0cb010e1
commit d3def16584

@ -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_export]
macro_rules! ctrl { macro_rules! ctrl {
($key:ident) => { ($key:ident) => {

@ -1,6 +1,6 @@
use crate::{ use crate::{
compositor::{Component, Compositor, Context, EventResult}, compositor::{Component, Compositor, Context, EventResult},
ctrl, key, ctrl, key, shift,
}; };
use crossterm::event::Event; use crossterm::event::Event;
use tui::{buffer::Buffer as Surface, widgets::Table}; use tui::{buffer::Buffer as Surface, widgets::Table};
@ -202,7 +202,7 @@ impl<T: Item + 'static> Component for Menu<T> {
return close_fn; return close_fn;
} }
// arrow up/ctrl-p/shift-tab prev completion choice (including updating the doc) // 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.move_up();
(self.callback_fn)(cx.editor, self.selection(), MenuEvent::Update); (self.callback_fn)(cx.editor, self.selection(), MenuEvent::Update);
return EventResult::Consumed(None); return EventResult::Consumed(None);

@ -1,6 +1,6 @@
use crate::{ use crate::{
compositor::{Component, Compositor, Context, EventResult}, compositor::{Component, Compositor, Context, EventResult},
ctrl, key, ctrl, key, shift,
ui::EditorView, ui::EditorView,
}; };
use crossterm::event::Event; use crossterm::event::Event;
@ -404,7 +404,7 @@ impl<T: 'static> Component for Picker<T> {
}))); })));
match key_event.into() { match key_event.into() {
key!(BackTab) | key!(Up) | ctrl!('p') | ctrl!('k') => { shift!(BackTab) | key!(Up) | ctrl!('p') | ctrl!('k') => {
self.move_up(); self.move_up();
} }
key!(Tab) | key!(Down) | ctrl!('n') | ctrl!('j') => { key!(Tab) | key!(Down) | ctrl!('n') | ctrl!('j') => {

@ -1,5 +1,5 @@
use crate::compositor::{Component, Compositor, Context, EventResult}; 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 crossterm::event::Event;
use helix_view::input::KeyEvent; use helix_view::input::KeyEvent;
use helix_view::keyboard::{KeyCode, KeyModifiers}; use helix_view::keyboard::{KeyCode, KeyModifiers};
@ -496,7 +496,7 @@ impl Component for Prompt {
self.change_completion_selection(CompletionDirection::Forward); self.change_completion_selection(CompletionDirection::Forward);
(self.callback_fn)(cx, &self.line, PromptEvent::Update) (self.callback_fn)(cx, &self.line, PromptEvent::Update)
} }
key!(BackTab) => { shift!(BackTab) => {
self.change_completion_selection(CompletionDirection::Backward); self.change_completion_selection(CompletionDirection::Backward);
(self.callback_fn)(cx, &self.line, PromptEvent::Update) (self.callback_fn)(cx, &self.line, PromptEvent::Update)
} }

Loading…
Cancel
Save