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

Function expandSelection

lib/web/CodeMirror/keymap/vim.js:3176–3198  ·  view source on GitHub ↗
(cm, start, end)

Source from the content-addressed store, hash-verified

3174 'visualBlock': vim.visualBlock};
3175 }
3176 function expandSelection(cm, start, end) {
3177 var sel = cm.state.vim.sel;
3178 var head = sel.head;
3179 var anchor = sel.anchor;
3180 var tmp;
3181 if (cursorIsBefore(end, start)) {
3182 tmp = end;
3183 end = start;
3184 start = tmp;
3185 }
3186 if (cursorIsBefore(head, anchor)) {
3187 head = cursorMin(start, head);
3188 anchor = cursorMax(anchor, end);
3189 } else {
3190 anchor = cursorMin(start, anchor);
3191 head = cursorMax(head, end);
3192 head = offsetCursor(head, 0, -1);
3193 if (head.ch == -1 && head.line != cm.firstLine()) {
3194 head = Pos(head.line - 1, lineLength(cm, head.line - 1));
3195 }
3196 }
3197 return [anchor, head];
3198 }
3199 /**
3200 * Updates the CodeMirror selection to match the provided vim selection.
3201 * If no arguments are given, it uses the current vim selection state.

Callers 1

VimFunction · 0.85

Calls 6

cursorIsBeforeFunction · 0.85
cursorMinFunction · 0.85
cursorMaxFunction · 0.85
offsetCursorFunction · 0.70
lineLengthFunction · 0.70
PosFunction · 0.50

Tested by

no test coverage detected