* Repeats the last edit, which includes exactly 1 command and at most 1 * insert. Operator and motion commands are read from lastEditInputState, * while action commands are read from lastEditActionCommand. * * If repeatForInsert is true, then the function was called by * exi
(cm, vim, repeat, repeatForInsert)
| 14314 | * corresponding enterInsertMode call was made with a count. |
| 14315 | */ |
| 14316 | function repeatLastEdit(cm, vim, repeat, repeatForInsert) { |
| 14317 | var macroModeState = vimGlobalState.macroModeState; |
| 14318 | macroModeState.isPlaying = true; |
| 14319 | var isAction = !!vim.lastEditActionCommand; |
| 14320 | var cachedInputState = vim.inputState; |
| 14321 | function repeatCommand() { |
| 14322 | if (isAction) { |
| 14323 | commandDispatcher.processAction(cm, vim, vim.lastEditActionCommand); |
| 14324 | } else { |
| 14325 | commandDispatcher.evalInput(cm, vim); |
| 14326 | } |
| 14327 | } |
| 14328 | function repeatInsert(repeat) { |
| 14329 | if (macroModeState.lastInsertModeChanges.changes.length > 0) { |
| 14330 | // For some reason, repeat cw in desktop VIM does not repeat |
| 14331 | // insert mode changes. Will conform to that behavior. |
| 14332 | repeat = !vim.lastEditActionCommand ? 1 : repeat; |
| 14333 | var changeObject = macroModeState.lastInsertModeChanges; |
| 14334 | repeatInsertModeChanges(cm, changeObject.changes, repeat); |
| 14335 | } |
| 14336 | } |
| 14337 | vim.inputState = vim.lastEditInputState; |
| 14338 | if (isAction && vim.lastEditActionCommand.interlaceInsertRepeat) { |
| 14339 | // o and O repeat have to be interlaced with insert repeats so that the |
| 14340 | // insertions appear on separate lines instead of the last line. |
| 14341 | for (var i = 0; i < repeat; i++) { |
| 14342 | repeatCommand(); |
| 14343 | repeatInsert(1); |
| 14344 | } |
| 14345 | } else { |
| 14346 | if (!repeatForInsert) { |
| 14347 | // Hack to get the cursor to end up at the right place. If I is |
| 14348 | // repeated in insert mode repeat, cursor will be 1 insert |
| 14349 | // change set left of where it should be. |
| 14350 | repeatCommand(); |
| 14351 | } |
| 14352 | repeatInsert(repeat); |
| 14353 | } |
| 14354 | vim.inputState = cachedInputState; |
| 14355 | if (vim.insertMode && !repeatForInsert) { |
| 14356 | // Don't exit insert mode twice. If repeatForInsert is set, then we |
| 14357 | // were called by an exitInsertMode call lower on the stack. |
| 14358 | exitInsertMode(cm); |
| 14359 | } |
| 14360 | macroModeState.isPlaying = false; |
| 14361 | }; |
| 14362 | |
| 14363 | function repeatInsertModeChanges(cm, changes, repeat) { |
| 14364 | function keyHandler(binding) { |
no test coverage detected