* 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)
| 5621 | * corresponding enterInsertMode call was made with a count. |
| 5622 | */ |
| 5623 | function repeatLastEdit(cm, vim, repeat, repeatForInsert) { |
| 5624 | var macroModeState = vimGlobalState.macroModeState; |
| 5625 | macroModeState.isPlaying = true; |
| 5626 | var isAction = !!vim.lastEditActionCommand; |
| 5627 | var cachedInputState = vim.inputState; |
| 5628 | function repeatCommand() { |
| 5629 | if (isAction) { |
| 5630 | commandDispatcher.processAction(cm, vim, vim.lastEditActionCommand); |
| 5631 | } else { |
| 5632 | commandDispatcher.evalInput(cm, vim); |
| 5633 | } |
| 5634 | } |
| 5635 | function repeatInsert(repeat) { |
| 5636 | if (macroModeState.lastInsertModeChanges.changes.length > 0) { |
| 5637 | // For some reason, repeat cw in desktop VIM does not repeat |
| 5638 | // insert mode changes. Will conform to that behavior. |
| 5639 | repeat = !vim.lastEditActionCommand ? 1 : repeat; |
| 5640 | var changeObject = macroModeState.lastInsertModeChanges; |
| 5641 | repeatInsertModeChanges(cm, changeObject.changes, repeat); |
| 5642 | } |
| 5643 | } |
| 5644 | vim.inputState = vim.lastEditInputState; |
| 5645 | if (isAction && vim.lastEditActionCommand.interlaceInsertRepeat) { |
| 5646 | // o and O repeat have to be interlaced with insert repeats so that the |
| 5647 | // insertions appear on separate lines instead of the last line. |
| 5648 | for (var i = 0; i < repeat; i++) { |
| 5649 | repeatCommand(); |
| 5650 | repeatInsert(1); |
| 5651 | } |
| 5652 | } else { |
| 5653 | if (!repeatForInsert) { |
| 5654 | // Hack to get the cursor to end up at the right place. If I is |
| 5655 | // repeated in insert mode repeat, cursor will be 1 insert |
| 5656 | // change set left of where it should be. |
| 5657 | repeatCommand(); |
| 5658 | } |
| 5659 | repeatInsert(repeat); |
| 5660 | } |
| 5661 | vim.inputState = cachedInputState; |
| 5662 | if (vim.insertMode && !repeatForInsert) { |
| 5663 | // Don't exit insert mode twice. If repeatForInsert is set, then we |
| 5664 | // were called by an exitInsertMode call lower on the stack. |
| 5665 | exitInsertMode(cm); |
| 5666 | } |
| 5667 | macroModeState.isPlaying = false; |
| 5668 | } |
| 5669 | |
| 5670 | function repeatInsertModeChanges(cm, changes, repeat) { |
| 5671 | function keyHandler(binding) { |
no test coverage detected