MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / exitInsertMode

Function exitInsertMode

lib/web/CodeMirror/keymap/vim.js:5341–5369  ·  view source on GitHub ↗
(cm)

Source from the content-addressed store, hash-verified

5339 };
5340
5341 function exitInsertMode(cm) {
5342 var vim = cm.state.vim;
5343 var macroModeState = vimGlobalState.macroModeState;
5344 var insertModeChangeRegister = vimGlobalState.registerController.getRegister('.');
5345 var isPlaying = macroModeState.isPlaying;
5346 var lastChange = macroModeState.lastInsertModeChanges;
5347 if (!isPlaying) {
5348 cm.off('change', onChange);
5349 CodeMirror.off(cm.getInputField(), 'keydown', onKeyEventTargetKeyDown);
5350 }
5351 if (!isPlaying && vim.insertModeRepeat > 1) {
5352 // Perform insert mode repeat for commands like 3,a and 3,o.
5353 repeatLastEdit(cm, vim, vim.insertModeRepeat - 1,
5354 true /** repeatForInsert */);
5355 vim.lastEditInputState.repeatOverride = vim.insertModeRepeat;
5356 }
5357 delete vim.insertModeRepeat;
5358 vim.insertMode = false;
5359 cm.setCursor(cm.getCursor().line, cm.getCursor().ch-1);
5360 cm.setOption('keyMap', 'vim');
5361 cm.setOption('disableInput', true);
5362 cm.toggleOverwrite(false); // exit replace mode if we were in it.
5363 // update the ". register before exiting insert mode
5364 insertModeChangeRegister.setText(lastChange.changes.join(''));
5365 CodeMirror.signal(cm, "vim-mode-change", {mode: "normal"});
5366 if (macroModeState.isRecording) {
5367 logInsertModeChange(macroModeState);
5368 }
5369 }
5370
5371 function _mapCommand(command) {
5372 defaultKeymap.unshift(command);

Callers 3

handleEscFunction · 0.85
executeMacroRegisterFunction · 0.85
repeatLastEditFunction · 0.85

Calls 5

repeatLastEditFunction · 0.85
logInsertModeChangeFunction · 0.85
setOptionMethod · 0.80
signalMethod · 0.80
offMethod · 0.45

Tested by

no test coverage detected