MCPcopy Create free account
hub / github.com/witheve/Eve / getLastSelectedAreaRange

Function getLastSelectedAreaRange

src/codemirror.js:12174–12205  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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();

Callers 1

getSelectedAreaRangeFunction · 0.85

Calls 4

lineLengthFunction · 0.85
getCursorMethod · 0.80
setSelectionMethod · 0.80
findMethod · 0.65

Tested by

no test coverage detected