MCPcopy Create free account
hub / github.com/TruthHun/BookStack / extendRange

Function extendRange

static/editor.md/lib/codemirror/lib/codemirror.js:2020–2036  ·  view source on GitHub ↗
(doc, range, head, other)

Source from the content-addressed store, hash-verified

2018 // Otherwise, simply returns the range between the given positions.
2019 // Used for cursor motion and such.
2020 function extendRange(doc, range, head, other) {
2021 if (doc.cm && doc.cm.display.shift || doc.extend) {
2022 var anchor = range.anchor;
2023 if (other) {
2024 var posBefore = cmp(head, anchor) < 0;
2025 if (posBefore != (cmp(other, anchor) < 0)) {
2026 anchor = head;
2027 head = other;
2028 } else if (posBefore != (cmp(head, other) < 0)) {
2029 head = other;
2030 }
2031 }
2032 return new Range(anchor, head);
2033 } else {
2034 return new Range(other || head, head);
2035 }
2036 }
2037
2038 // Extend the primary selection range, discard the rest.
2039 function extendSelection(doc, head, other, options) {

Callers 3

extendSelectionFunction · 0.70
extendSelectionsFunction · 0.70
leftButtonSelectFunction · 0.70

Calls 1

cmpFunction · 0.50

Tested by

no test coverage detected