From 45870abe7b723f93f3147fa3e35f835da1215f4a Mon Sep 17 00:00:00 2001 From: Alex Ford Date: Thu, 7 Jul 2022 17:43:44 -0700 Subject: [PATCH 1/4] Rebind Esc to move "up" mode insert->normal->command. --- src/labCommands.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/labCommands.ts b/src/labCommands.ts index 4546cc2..fd42de8 100644 --- a/src/labCommands.ts +++ b/src/labCommands.ts @@ -143,6 +143,29 @@ export function addJLabCommands( }, isEnabled }), + commands.addCommand('vim:leave-current-mode', { + label: 'Move Insert to Normal to Command Mode"', + execute: args => { + const current = getCurrent(args); + + if (current) { + const { content } = current; + if (content.activeCell !== null) { + let editor = content.activeCell.editor as CodeMirrorEditor; + + // Get the current editor state + if(editor.editor.state.vim.insertMode) { + (CodeMirror as any).Vim.handleKey(editor.editor, ''); + } else if (editor.editor.state.vim.visualMode){ + (CodeMirror as any).Vim.handleKey(editor.editor, ''); + } else { + commands.execute('notebook:enter-command-mode'); + } + } + } + }, + isEnabled + }), commands.addCommand('vim:select-below-execute-markdown', { label: 'Execute Markdown and Select Cell Below', execute: args => { From 7daf2187fd33ebbb26924ceb8292cad36deceec1 Mon Sep 17 00:00:00 2001 From: Alex Ford Date: Sat, 1 Oct 2022 12:19:23 -0700 Subject: [PATCH 2/4] Add note to history --- History.md | 1 + 1 file changed, 1 insertion(+) diff --git a/History.md b/History.md index 7a0a619..39f4d23 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,7 @@ # History ## Next + * Add bindable command to move insert-to-normal-to-command modes (#69) ## 0.15.1 / 2022-03-12 * Fixed a bug in `0.15.0` where you could no longer type `c`. From 6d2172f3120332ce3958a3f0c6e204cb225836ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Krassowski?= <5832902+krassowski@users.noreply.github.com> Date: Sun, 5 Feb 2023 20:11:08 +0000 Subject: [PATCH 3/4] Apply suggestions from code review Co-authored-by: Ian Hunt-Isaak --- src/labCommands.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/labCommands.ts b/src/labCommands.ts index fd42de8..53f9f0c 100644 --- a/src/labCommands.ts +++ b/src/labCommands.ts @@ -144,7 +144,7 @@ export function addJLabCommands( isEnabled }), commands.addCommand('vim:leave-current-mode', { - label: 'Move Insert to Normal to Command Mode"', + label: 'Move Insert to Normal to Jupyter Command Mode"', execute: args => { const current = getCurrent(args); @@ -154,9 +154,7 @@ export function addJLabCommands( let editor = content.activeCell.editor as CodeMirrorEditor; // Get the current editor state - if(editor.editor.state.vim.insertMode) { - (CodeMirror as any).Vim.handleKey(editor.editor, ''); - } else if (editor.editor.state.vim.visualMode){ + if (editor.editor.state.vim.insertMode || editor.editor.state.vim.visualMode) { (CodeMirror as any).Vim.handleKey(editor.editor, ''); } else { commands.execute('notebook:enter-command-mode'); From ed56d27c03124c37b247b700879d196ec8ac9f10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Krassowski?= <5832902+krassowski@users.noreply.github.com> Date: Sun, 12 Mar 2023 22:45:59 +0000 Subject: [PATCH 4/4] Lint --- src/labCommands.ts | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/src/labCommands.ts b/src/labCommands.ts index 53f9f0c..bcffe19 100644 --- a/src/labCommands.ts +++ b/src/labCommands.ts @@ -144,25 +144,28 @@ export function addJLabCommands( isEnabled }), commands.addCommand('vim:leave-current-mode', { - label: 'Move Insert to Normal to Jupyter Command Mode"', - execute: args => { - const current = getCurrent(args); - - if (current) { - const { content } = current; - if (content.activeCell !== null) { - let editor = content.activeCell.editor as CodeMirrorEditor; - - // Get the current editor state - if (editor.editor.state.vim.insertMode || editor.editor.state.vim.visualMode) { - (CodeMirror as any).Vim.handleKey(editor.editor, ''); - } else { - commands.execute('notebook:enter-command-mode'); - } - } + label: 'Move Insert to Normal to Jupyter Command Mode"', + execute: args => { + const current = getCurrent(args); + + if (current) { + const { content } = current; + if (content.activeCell !== null) { + const editor = content.activeCell.editor as CodeMirrorEditor; + + // Get the current editor state + if ( + editor.editor.state.vim.insertMode || + editor.editor.state.vim.visualMode + ) { + (CodeMirror as any).Vim.handleKey(editor.editor, ''); + } else { + commands.execute('notebook:enter-command-mode'); } - }, - isEnabled + } + } + }, + isEnabled }), commands.addCommand('vim:select-below-execute-markdown', { label: 'Execute Markdown and Select Cell Below',