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

Function handleKeyInsertMode

lib/web/CodeMirror/keymap/vim.js:907–938  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

905 }
906
907 function handleKeyInsertMode() {
908 if (handleEsc()) { return true; }
909 var keys = vim.inputState.keyBuffer = vim.inputState.keyBuffer + key;
910 var keysAreChars = key.length == 1;
911 var match = commandDispatcher.matchCommand(keys, defaultKeymap, vim.inputState, 'insert');
912 // Need to check all key substrings in insert mode.
913 while (keys.length > 1 && match.type != 'full') {
914 var keys = vim.inputState.keyBuffer = keys.slice(1);
915 var thisMatch = commandDispatcher.matchCommand(keys, defaultKeymap, vim.inputState, 'insert');
916 if (thisMatch.type != 'none') { match = thisMatch; }
917 }
918 if (match.type == 'none') { clearInputState(cm); return false; }
919 else if (match.type == 'partial') {
920 if (lastInsertModeKeyTimer) { window.clearTimeout(lastInsertModeKeyTimer); }
921 lastInsertModeKeyTimer = window.setTimeout(
922 function() { if (vim.insertMode && vim.inputState.keyBuffer) { clearInputState(cm); } },
923 getOption('insertModeEscKeysTimeout'));
924 return !keysAreChars;
925 }
926
927 if (lastInsertModeKeyTimer) { window.clearTimeout(lastInsertModeKeyTimer); }
928 if (keysAreChars) {
929 var selections = cm.listSelections();
930 for (var i = 0; i < selections.length; i++) {
931 var here = selections[i].head;
932 cm.replaceRange('', offsetCursor(here, 0, -(keys.length - 1)), here, '+input');
933 }
934 vimGlobalState.macroModeState.lastInsertModeChanges.changes.pop();
935 }
936 clearInputState(cm);
937 return match.command;
938 }
939
940 function handleKeyNonInsertMode() {
941 if (handleMacroRecording() || handleEsc()) { return true; }

Callers 1

VimFunction · 0.85

Calls 6

handleEscFunction · 0.85
clearInputStateFunction · 0.85
replaceRangeMethod · 0.80
getOptionFunction · 0.70
offsetCursorFunction · 0.70
popMethod · 0.45

Tested by

no test coverage detected