mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-11-09 13:44:53 +08:00
Fix editor escape in Vim visual mode (#2178)
Co-authored-by: Jonatan Kłosko <jonatanklosko@gmail.com>
This commit is contained in:
parent
c06712fa67
commit
c04f43d936
2 changed files with 19 additions and 12 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue