MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / getLastSelectedAreaRange

Function getLastSelectedAreaRange

lib/web/CodeMirror/keymap/vim.js:3119–3150  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3117 return [selectionStart, selectionEnd];
3118 };
3119 var getLastSelectedAreaRange = function() {
3120 var selectionStart = cm.getCursor();
3121 var selectionEnd = cm.getCursor();
3122 var block = lastSelection.visualBlock;
3123 if (block) {
3124 var width = block.width;
3125 var height = block.height;
3126 selectionEnd = Pos(selectionStart.line + height, selectionStart.ch + width);
3127 var selections = [];
3128 // selectBlock creates a 'proper' rectangular block.
3129 // We do not want that in all cases, so we manually set selections.
3130 for (var i = selectionStart.line; i < selectionEnd.line; i++) {
3131 var anchor = Pos(i, selectionStart.ch);
3132 var head = Pos(i, selectionEnd.ch);
3133 var range = {anchor: anchor, head: head};
3134 selections.push(range);
3135 }
3136 cm.setSelections(selections);
3137 } else {
3138 var start = lastSelection.anchorMark.find();
3139 var end = lastSelection.headMark.find();
3140 var line = end.line - start.line;
3141 var ch = end.ch - start.ch;
3142 selectionEnd = {line: selectionEnd.line + line, ch: line ? selectionEnd.ch : ch + selectionEnd.ch};
3143 if (lastSelection.visualLine) {
3144 selectionStart = Pos(selectionStart.line, 0);
3145 selectionEnd = Pos(selectionEnd.line, lineLength(cm, selectionEnd.line));
3146 }
3147 cm.setSelection(selectionStart, selectionEnd);
3148 }
3149 return [selectionStart, selectionEnd];
3150 };
3151 if (!vim.visualMode) {
3152 // In case of replaying the action.
3153 return getLastSelectedAreaRange();

Callers 1

getSelectedAreaRangeFunction · 0.85

Calls 4

lineLengthFunction · 0.70
PosFunction · 0.50
pushMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected