Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
run: () => {
if (vimMode) {
vimMode.dispose();
}
setVimMode(initVimMode(editor));
},
});
public onVimKeybind() {
if (this.vimMode) {
this.vimMode.dispose();
if (this.statusNode) {
this.statusNode.innerHTML = "";
}
this.vimMode = null;
return;
}
this.statusNode = document.getElementById("vim-status-bar");
this.vimMode = initVimMode(this.editorInstance, this.statusNode);
return;
}
public render() {
_toggleMode = mode => {
if (mode === 'vim') {
this._vim = initVimMode(this._editor, this._statusbar);
} else {
this._vim && this._vim.dispose();
}
};
useEffect(() => {
if (!editorRef.current || !statusBarRef.current) {
return
}
keybindingRef.current?.dispose()
switch (keybindings) {
case Keybindings.VIM:
keybindingRef.current = initVimMode(
editorRef.current,
statusBarRef.current
)
break
case Keybindings.EMACS:
const extension = new EmacsExtension(editorRef.current)
extension.start()
keybindingRef.current = extension
break
}
}, [editorRef, statusBarRef, keybindings, keybindingRef])
onVimKeybind(e) {
if (this.vimMode) {
this.vimMode.dispose();
this.statusNode.innerHTML = '';
this.vimMode = null;
return;
}
this.statusNode = document.getElementById('vim-status-bar');
this.vimMode = initVimMode(this.editorInstance, this.statusNode);
return;
}
render() {
Editor.prototype.enableVim = function () {
this.vimMode = monacoVim.initVimMode(this.editor, this.domRoot.find('#v-status')[0]);
this.vimFlag.prop("class", "btn btn-info");
this.editor.vimInUse = true;
};
_toggleMode = (mode: EditorMode) => {
if (mode === 'vim' && this._editor) {
this._vim = initVimMode(this._editor, this._statusbar.current as HTMLDivElement);
} else {
this._vim && this._vim.dispose();
}
};
export const enableVim = (editor, el) => {
const statusEl = el.querySelector('#deepword-vim');
statusEl.innerHTML = '';
vimMode = initVimMode(editor, statusEl);
};
Editor.prototype.onInsertKey = function (event) {
if (this.editor.vimInUse) {
var currentState = monacoVim.VimMode.Vim.maybeInitVimState_(this.vimMode);
if (!currentState.insertMode) {
var insertEvent = {};
insertEvent.preventDefault = event.preventDefault;
insertEvent.stopPropagation = event.stopPropagation;
insertEvent.browserEvent = {};
insertEvent.browserEvent.key = 'i';
insertEvent.browserEvent.defaultPrevented = false;
insertEvent.keyCode = 39;
this.vimMode.handleKeyDown(insertEvent);
}
}
};
Editor.prototype.onEscapeKey = function () {
if (this.editor.vimInUse) {
var currentState = monacoVim.VimMode.Vim.maybeInitVimState_(this.vimMode);
if (currentState.insertMode) {
monacoVim.VimMode.Vim.exitInsertMode(this.vimMode);
} else if (currentState.visualMode) {
monacoVim.VimMode.Vim.exitVisualMode(this.vimMode, false);
}
}
};