()
| 12172 | return [selectionStart, selectionEnd]; |
| 12173 | }; |
| 12174 | var getLastSelectedAreaRange = function() { |
| 12175 | var selectionStart = cm.getCursor(); |
| 12176 | var selectionEnd = cm.getCursor(); |
| 12177 | var block = lastSelection.visualBlock; |
| 12178 | if (block) { |
| 12179 | var width = block.width; |
| 12180 | var height = block.height; |
| 12181 | selectionEnd = Pos(selectionStart.line + height, selectionStart.ch + width); |
| 12182 | var selections = []; |
| 12183 | // selectBlock creates a 'proper' rectangular block. |
| 12184 | // We do not want that in all cases, so we manually set selections. |
| 12185 | for (var i = selectionStart.line; i < selectionEnd.line; i++) { |
| 12186 | var anchor = Pos(i, selectionStart.ch); |
| 12187 | var head = Pos(i, selectionEnd.ch); |
| 12188 | var range = {anchor: anchor, head: head}; |
| 12189 | selections.push(range); |
| 12190 | } |
| 12191 | cm.setSelections(selections); |
| 12192 | } else { |
| 12193 | var start = lastSelection.anchorMark.find(); |
| 12194 | var end = lastSelection.headMark.find(); |
| 12195 | var line = end.line - start.line; |
| 12196 | var ch = end.ch - start.ch; |
| 12197 | selectionEnd = {line: selectionEnd.line + line, ch: line ? selectionEnd.ch : ch + selectionEnd.ch}; |
| 12198 | if (lastSelection.visualLine) { |
| 12199 | selectionStart = Pos(selectionStart.line, 0); |
| 12200 | selectionEnd = Pos(selectionEnd.line, lineLength(cm, selectionEnd.line)); |
| 12201 | } |
| 12202 | cm.setSelection(selectionStart, selectionEnd); |
| 12203 | } |
| 12204 | return [selectionStart, selectionEnd]; |
| 12205 | }; |
| 12206 | if (!vim.visualMode) { |
| 12207 | // In case of replaying the action. |
| 12208 | return getLastSelectedAreaRange(); |
no test coverage detected