Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "leave-current-mode" command to move insert->normal->command. #69

Merged
merged 4 commits into from
Mar 12, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -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`.
Expand Down
23 changes: 23 additions & 0 deletions src/labCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,29 @@ export function addJLabCommands(
},
isEnabled
}),
commands.addCommand('vim:leave-current-mode', {
label: 'Move Insert to Normal to Command Mode"',
krassowski marked this conversation as resolved.
Show resolved Hide resolved
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, '<Esc>');
} else if (editor.editor.state.vim.visualMode){
(CodeMirror as any).Vim.handleKey(editor.editor, '<Esc>');
krassowski marked this conversation as resolved.
Show resolved Hide resolved
} else {
commands.execute('notebook:enter-command-mode');
}
}
}
},
isEnabled
}),
commands.addCommand('vim:select-below-execute-markdown', {
label: 'Execute Markdown and Select Cell Below',
execute: args => {
Expand Down