mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-11-10 06:01:44 +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();
|
this._initializeWidgets();
|
||||||
|
|
||||||
// Set the editor mode
|
// Set the editor mode
|
||||||
if (settings.editor_mode == "emacs") {
|
this._setEditorMode(settings.editor_mode);
|
||||||
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);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -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) {
|
function completionItemsToSuggestions(items, settings) {
|
||||||
|
|
|
||||||
|
|
@ -469,8 +469,8 @@ const Session = {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Vim insert mode
|
// Vim insert or visual mode
|
||||||
if (editor.dataset.vimMode == "insert") {
|
if (["insert", "visual"].includes(editor.dataset.vimMode)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue