MCPcopy
hub / github.com/DHTMLX/gantt / extendTo

Function extendTo

samples/common/codehighlight/codemirror.js:7479–7515  ·  view source on GitHub ↗
(pos)

Source from the content-addressed store, hash-verified

7477
7478 var lastPos = start;
7479 function extendTo(pos) {
7480 if (cmp(lastPos, pos) == 0) { return }
7481 lastPos = pos;
7482
7483 if (behavior.unit == "rectangle") {
7484 var ranges = [], tabSize = cm.options.tabSize;
7485 var startCol = countColumn(getLine(doc, start.line).text, start.ch, tabSize);
7486 var posCol = countColumn(getLine(doc, pos.line).text, pos.ch, tabSize);
7487 var left = Math.min(startCol, posCol), right = Math.max(startCol, posCol);
7488 for (var line = Math.min(start.line, pos.line), end = Math.min(cm.lastLine(), Math.max(start.line, pos.line));
7489 line <= end; line++) {
7490 var text = getLine(doc, line).text, leftPos = findColumn(text, left, tabSize);
7491 if (left == right)
7492 { ranges.push(new Range(Pos(line, leftPos), Pos(line, leftPos))); }
7493 else if (text.length > leftPos)
7494 { ranges.push(new Range(Pos(line, leftPos), Pos(line, findColumn(text, right, tabSize)))); }
7495 }
7496 if (!ranges.length) { ranges.push(new Range(start, start)); }
7497 setSelection(doc, normalizeSelection(cm, startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex),
7498 {origin: "*mouse", scroll: false});
7499 cm.scrollIntoView(pos);
7500 } else {
7501 var oldRange = ourRange;
7502 var range = rangeForUnit(cm, pos, behavior.unit);
7503 var anchor = oldRange.anchor, head;
7504 if (cmp(range.anchor, anchor) > 0) {
7505 head = range.head;
7506 anchor = minPos(oldRange.from(), range.anchor);
7507 } else {
7508 head = range.anchor;
7509 anchor = maxPos(oldRange.to(), range.head);
7510 }
7511 var ranges$1 = startSel.ranges.slice(0);
7512 ranges$1[ourIndex] = bidiSimplify(cm, new Range(clipPos(doc, anchor), head));
7513 setSelection(doc, normalizeSelection(cm, ranges$1, ourIndex), sel_mouse);
7514 }
7515 }
7516
7517 var editorSize = display.wrapper.getBoundingClientRect();
7518 // Used to ensure timeout re-tries don't fire when another extend

Callers 1

extendFunction · 0.85

Calls 12

cmpFunction · 0.85
countColumnFunction · 0.85
getLineFunction · 0.85
findColumnFunction · 0.85
PosFunction · 0.85
setSelectionFunction · 0.85
normalizeSelectionFunction · 0.85
rangeForUnitFunction · 0.85
minPosFunction · 0.85
maxPosFunction · 0.85
bidiSimplifyFunction · 0.85
clipPosFunction · 0.85

Tested by

no test coverage detected