Fix editor escape in Vim visual mode (#2178)

Co-authored-by: Jonatan Kłosko <jonatanklosko@gmail.com>
This commit is contained in:
Kenichi Nakamura 2023-08-23 11:34:02 -07:00 committed by GitHub
parent c06712fa67
commit c04f43d936
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 12 deletions

View file

@ -371,16 +371,7 @@ class LiveEditor {
this._initializeWidgets();
// Set the editor mode
if (settings.editor_mode == "emacs") {
this.emacsMode = new EmacsExtension(this.editor);
this.emacsMode.start();
unregisterKey("Tab");
} else if (settings.editor_mode == "vim") {
this.vimMode = initVimMode(this.editor);
this.vimMode.on("vim-mode-change", ({ mode: mode }) => {
this.editor.getDomNode().setAttribute("data-vim-mode", mode);
});
}
this._setEditorMode(settings.editor_mode);
}
/**
@ -646,6 +637,22 @@ class LiveEditor {
);
});
}
/**
* Sets Monaco editor mode via monaco-emacs or monaco-vim packages.
*/
_setEditorMode(editorMode) {
if (editorMode == "emacs") {
this.emacsMode = new EmacsExtension(this.editor);
this.emacsMode.start();
unregisterKey("Tab");
} else if (editorMode == "vim") {
this.vimMode = initVimMode(this.editor);
this.vimMode.on("vim-mode-change", ({ mode: mode }) => {
this.editor.getDomNode().setAttribute("data-vim-mode", mode);
});
}
}
}
function completionItemsToSuggestions(items, settings) {

View file

@ -469,8 +469,8 @@ const Session = {
return true;
}
// Vim insert mode
if (editor.dataset.vimMode == "insert") {
// Vim insert or visual mode
if (["insert", "visual"].includes(editor.dataset.vimMode)) {
return true;
}