MCPcopy
hub / github.com/witheve/Eve / expandSelection

Function expandSelection

src/codemirror.js:12231–12253  ·  view source on GitHub ↗
(cm, start, end)

Source from the content-addressed store, hash-verified

12229 'visualBlock': vim.visualBlock};
12230 }
12231 function expandSelection(cm, start, end) {
12232 var sel = cm.state.vim.sel;
12233 var head = sel.head;
12234 var anchor = sel.anchor;
12235 var tmp;
12236 if (cursorIsBefore(end, start)) {
12237 tmp = end;
12238 end = start;
12239 start = tmp;
12240 }
12241 if (cursorIsBefore(head, anchor)) {
12242 head = cursorMin(start, head);
12243 anchor = cursorMax(anchor, end);
12244 } else {
12245 anchor = cursorMin(start, anchor);
12246 head = cursorMax(head, end);
12247 head = offsetCursor(head, 0, -1);
12248 if (head.ch == -1 && head.line != cm.firstLine()) {
12249 head = Pos(head.line - 1, lineLength(cm, head.line - 1));
12250 }
12251 }
12252 return [anchor, head];
12253 }
12254 /**
12255 * Updates the CodeMirror selection to match the provided vim selection.
12256 * 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.85
lineLengthFunction · 0.85
firstLineMethod · 0.80

Tested by

no test coverage detected