()
| 10095 | } |
| 10096 | |
| 10097 | function handleKeyInsertMode() { |
| 10098 | if (handleEsc()) { return true; } |
| 10099 | var keys = vim.inputState.keyBuffer = vim.inputState.keyBuffer + key; |
| 10100 | var keysAreChars = key.length == 1; |
| 10101 | var match = commandDispatcher.matchCommand(keys, defaultKeymap, vim.inputState, 'insert'); |
| 10102 | // Need to check all key substrings in insert mode. |
| 10103 | while (keys.length > 1 && match.type != 'full') { |
| 10104 | var keys = vim.inputState.keyBuffer = keys.slice(1); |
| 10105 | var thisMatch = commandDispatcher.matchCommand(keys, defaultKeymap, vim.inputState, 'insert'); |
| 10106 | if (thisMatch.type != 'none') { match = thisMatch; } |
| 10107 | } |
| 10108 | if (match.type == 'none') { clearInputState(cm); return false; } |
| 10109 | else if (match.type == 'partial') { |
| 10110 | if (lastInsertModeKeyTimer) { window.clearTimeout(lastInsertModeKeyTimer); } |
| 10111 | lastInsertModeKeyTimer = window.setTimeout( |
| 10112 | function() { if (vim.insertMode && vim.inputState.keyBuffer) { clearInputState(cm); } }, |
| 10113 | getOption('insertModeEscKeysTimeout')); |
| 10114 | return !keysAreChars; |
| 10115 | } |
| 10116 | |
| 10117 | if (lastInsertModeKeyTimer) { window.clearTimeout(lastInsertModeKeyTimer); } |
| 10118 | if (keysAreChars) { |
| 10119 | var here = cm.getCursor(); |
| 10120 | cm.replaceRange('', offsetCursor(here, 0, -(keys.length - 1)), here, '+input'); |
| 10121 | } |
| 10122 | clearInputState(cm); |
| 10123 | return match.command; |
| 10124 | } |
| 10125 | |
| 10126 | function handleKeyNonInsertMode() { |
| 10127 | if (handleMacroRecording() || handleEsc()) { return true; }; |
no test coverage detected