Skip to content

Commit

Permalink
removed shift matching
Browse files Browse the repository at this point in the history
  • Loading branch information
janhrastnik authored and archseer committed Jun 3, 2021
1 parent abe8a83 commit 712f25c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 25 deletions.
39 changes: 15 additions & 24 deletions helix-term/src/keymap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,6 @@ macro_rules! key {
};
}

macro_rules! shift {
($($ch:tt)*) => {
KeyEvent {
code: KeyCode::Char($($ch)*),
modifiers: KeyModifiers::SHIFT,
}
};
}

macro_rules! ctrl {
($($ch:tt)*) => {
KeyEvent {
Expand Down Expand Up @@ -139,8 +130,8 @@ pub fn default() -> Keymaps {

key!('t') => commands::find_till_char,
key!('f') => commands::find_next_char,
shift!('T') => commands::till_prev_char,
shift!('F') => commands::find_prev_char,
key!('T') => commands::till_prev_char,
key!('F') => commands::find_prev_char,
// and matching set for select mode (extend)
//
key!('r') => commands::replace,
Expand All @@ -157,11 +148,11 @@ pub fn default() -> Keymaps {
key!(':') => commands::command_mode,

key!('i') => commands::insert_mode,
shift!('I') => commands::prepend_to_line,
key!('I') => commands::prepend_to_line,
key!('a') => commands::append_mode,
shift!('A') => commands::append_to_line,
key!('A') => commands::append_to_line,
key!('o') => commands::open_below,
shift!('O') => commands::open_above,
key!('O') => commands::open_above,
// [<space> ]<space> equivalents too (add blank new line, no edit)


Expand All @@ -174,12 +165,12 @@ pub fn default() -> Keymaps {

key!('s') => commands::select_regex,
alt!('s') => commands::split_selection_on_newline,
shift!('S') => commands::split_selection,
key!('S') => commands::split_selection,
key!(';') => commands::collapse_selection,
alt!(';') => commands::flip_selections,
key!('%') => commands::select_all,
key!('x') => commands::select_line,
shift!('X') => commands::extend_line,
key!('X') => commands::extend_line,
// or select mode X?
// extend_to_whole_line, crop_to_whole_line

Expand All @@ -199,25 +190,25 @@ pub fn default() -> Keymaps {
key!('/') => commands::search,
// ? for search_reverse
key!('n') => commands::search_next,
shift!('N') => commands::extend_search_next,
key!('N') => commands::extend_search_next,
// N for search_prev
key!('*') => commands::search_selection,

key!('u') => commands::undo,
shift!('U') => commands::redo,
key!('U') => commands::redo,

key!('y') => commands::yank,
// yank_all
key!('p') => commands::paste_after,
// paste_all
shift!('P') => commands::paste_before,
key!('P') => commands::paste_before,

key!('>') => commands::indent,
key!('<') => commands::unindent,
key!('=') => commands::format_selections,
shift!('J') => commands::join_selections,
key!('J') => commands::join_selections,
// TODO: conflicts hover/doc
shift!('K') => commands::keep_selections,
key!('K') => commands::keep_selections,
// TODO: and another method for inverse

// TODO: clashes with space mode
Expand Down Expand Up @@ -256,7 +247,7 @@ pub fn default() -> Keymaps {

// move under <space>c
ctrl!('c') => commands::toggle_comments,
shift!('K') => commands::hover,
key!('K') => commands::hover,

// z family for save/restore/combine from/to sels from register

Expand Down Expand Up @@ -284,8 +275,8 @@ pub fn default() -> Keymaps {

key!('t') => commands::extend_till_char,
key!('f') => commands::extend_next_char,
shift!('T') => commands::extend_till_prev_char,
shift!('F') => commands::extend_prev_char,
key!('T') => commands::extend_till_prev_char,
key!('F') => commands::extend_prev_char,

KeyEvent {
code: KeyCode::Esc,
Expand Down
7 changes: 6 additions & 1 deletion helix-term/src/ui/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,10 +543,15 @@ impl Component for EditorView {
cx.editor.resize(Rect::new(0, 0, width, height - 1));
EventResult::Consumed(None)
}
Event::Key(key) => {
Event::Key(mut key) => {
// clear status
cx.editor.status_msg = None;

//canonicalize the key
if key.modifiers == KeyModifiers::SHIFT {
key.modifiers = KeyModifiers::NONE;
}

let (view, doc) = cx.editor.current();
let mode = doc.mode();

Expand Down

0 comments on commit 712f25c

Please sign in to comment.