|
5079 | 5079 | var insertModeChangeRegister = vimGlobalState.registerController.getRegister('.'); |
5080 | 5080 | var isPlaying = macroModeState.isPlaying; |
5081 | 5081 | var lastChange = macroModeState.lastInsertModeChanges; |
5082 | | - // In case of visual block, the insertModeChanges are not saved as a |
5083 | | - // single word, so we convert them to a single word |
5084 | | - // so as to update the ". register as expected in real vim. |
5085 | | - var text = []; |
5086 | 5082 | if (!isPlaying) { |
5087 | | - var selLength = lastChange.inVisualBlock && vim.lastSelection ? |
5088 | | - vim.lastSelection.visualBlock.height : 1; |
5089 | | - var changes = lastChange.changes; |
5090 | | - var text = []; |
5091 | | - var i = 0; |
5092 | | - // In case of multiple selections in blockwise visual, |
5093 | | - // the inserted text, for example: 'f<Backspace>oo', is stored as |
5094 | | - // 'f', 'f', InsertModeKey 'o', 'o', 'o', 'o'. (if you have a block with 2 lines). |
5095 | | - // We push the contents of the changes array as per the following: |
5096 | | - // 1. In case of InsertModeKey, just increment by 1. |
5097 | | - // 2. In case of a character, jump by selLength (2 in the example). |
5098 | | - while (i < changes.length) { |
5099 | | - // This loop will convert 'ff<bs>oooo' to 'f<bs>oo'. |
5100 | | - text.push(changes[i]); |
5101 | | - if (changes[i] instanceof InsertModeKey) { |
5102 | | - i++; |
5103 | | - } else { |
5104 | | - i+= selLength; |
5105 | | - } |
5106 | | - } |
5107 | | - lastChange.changes = text; |
5108 | 5083 | cm.off('change', onChange); |
5109 | 5084 | CodeMirror.off(cm.getInputField(), 'keydown', onKeyEventTargetKeyDown); |
5110 | 5085 | } |
|
5235 | 5210 | if (!macroModeState.isPlaying) { |
5236 | 5211 | while(changeObj) { |
5237 | 5212 | lastChange.expectCursorActivityForChange = true; |
5238 | | - if (changeObj.origin == '+input' || changeObj.origin == 'paste' |
| 5213 | + if (lastChange.ignoreCount > 1) { |
| 5214 | + lastChange.ignoreCount--; |
| 5215 | + } else if (changeObj.origin == '+input' || changeObj.origin == 'paste' |
5239 | 5216 | || changeObj.origin === undefined /* only in testing */) { |
| 5217 | + var selectionCount = cm.listSelections().length; |
| 5218 | + if (selectionCount > 1) |
| 5219 | + lastChange.ignoreCount = selectionCount; |
5240 | 5220 | var text = changeObj.text.join('\n'); |
5241 | 5221 | if (lastChange.maybeReset) { |
5242 | 5222 | lastChange.changes = []; |
5243 | 5223 | lastChange.maybeReset = false; |
5244 | 5224 | } |
5245 | | - if (cm.state.overwrite && !/\n/.test(text)) { |
| 5225 | + if (text) { |
| 5226 | + if (cm.state.overwrite && !/\n/.test(text)) { |
5246 | 5227 | lastChange.changes.push([text]); |
5247 | | - } else { |
| 5228 | + } else { |
5248 | 5229 | lastChange.changes.push(text); |
| 5230 | + } |
5249 | 5231 | } |
5250 | 5232 | } |
5251 | 5233 | // Change objects may be chained with next. |
|
0 commit comments