From d224876d08d64cce31838317a41ba412c5fd78bd Mon Sep 17 00:00:00 2001 From: Kano Date: Sat, 2 Nov 2019 23:18:24 -0700 Subject: [PATCH 1/3] ctrl + [ support for exiting insert mode --- bundles/vi/insert_map.moon | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bundles/vi/insert_map.moon b/bundles/vi/insert_map.moon index 8f158d663..67d539fe5 100644 --- a/bundles/vi/insert_map.moon +++ b/bundles/vi/insert_map.moon @@ -33,6 +33,12 @@ insert_map = { state.change_mode editor, 'command' editor.cursor.column = math.max 1, editor.cursor.column - 1 + 'ctrl_[': (editor) -> + state.insert_edit = get_edit editor + insert_pos = nil + state.change_mode editor, 'command' + editor.cursor.column = math.max 1, editor.cursor.column - 1 + ctrl_i: (editor) -> editor\shift_right! ctrl_d: (editor) -> editor\shift_left! } From 6727545674c185d752d701c28c814b0699618769 Mon Sep 17 00:00:00 2001 From: reimage Date: Tue, 5 Nov 2019 08:18:23 -0800 Subject: [PATCH 2/3] Extracted code into a exit_insert_mode per contributor request --- bundles/vi/insert_map.moon | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/bundles/vi/insert_map.moon b/bundles/vi/insert_map.moon index 67d539fe5..9d4686651 100644 --- a/bundles/vi/insert_map.moon +++ b/bundles/vi/insert_map.moon @@ -14,6 +14,12 @@ get_edit = (editor) -> if text and #text > 0 (editor) -> editor\insert text +exit_insert_mode = (editor) -> + state.insert_edit = get_edit editor + insert_pos = nil + state.change_mode editor, 'command' + editor.cursor.column = math.max 1, editor.cursor.column - 1 + insert_map = { __meta: { @@ -27,22 +33,11 @@ insert_map = { blink_interval: -> config.cursor_blink_interval } - escape: (editor) -> - state.insert_edit = get_edit editor - insert_pos = nil - state.change_mode editor, 'command' - editor.cursor.column = math.max 1, editor.cursor.column - 1 - - 'ctrl_[': (editor) -> - state.insert_edit = get_edit editor - insert_pos = nil - state.change_mode editor, 'command' - editor.cursor.column = math.max 1, editor.cursor.column - 1 - + escape: (editor) -> exit_insert_mode editor + 'ctrl_[': (editor) -> exit_insert_mode editor ctrl_i: (editor) -> editor\shift_right! ctrl_d: (editor) -> editor\shift_left! } - setmetatable insert_map, { __call: (_, editor) -> state.enter_edit_mode editor From 9f8439dd8774edc96fe423073a34d3bb7e5bcda8 Mon Sep 17 00:00:00 2001 From: Kano Date: Thu, 7 Nov 2019 20:37:02 -0800 Subject: [PATCH 3/3] refactor deux --- bundles/vi/insert_map.moon | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bundles/vi/insert_map.moon b/bundles/vi/insert_map.moon index 9d4686651..1401415a0 100644 --- a/bundles/vi/insert_map.moon +++ b/bundles/vi/insert_map.moon @@ -33,8 +33,8 @@ insert_map = { blink_interval: -> config.cursor_blink_interval } - escape: (editor) -> exit_insert_mode editor - 'ctrl_[': (editor) -> exit_insert_mode editor + escape: exit_insert_mode + 'ctrl_[': exit_insert_mode ctrl_i: (editor) -> editor\shift_right! ctrl_d: (editor) -> editor\shift_left! }