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

Function extendRange

lib/web/CodeMirror/src/model/selection_updates.js:19–35  ·  view source on GitHub ↗
(range, head, other, extend)

Source from the content-addressed store, hash-verified

17// Otherwise, simply returns the range between the given positions.
18// Used for cursor motion and such.
19export function extendRange(range, head, other, extend) {
20 if (extend) {
21 let anchor = range.anchor
22 if (other) {
23 let posBefore = cmp(head, anchor) < 0
24 if (posBefore != (cmp(other, anchor) < 0)) {
25 anchor = head
26 head = other
27 } else if (posBefore != (cmp(head, other) < 0)) {
28 head = other
29 }
30 }
31 return new Range(anchor, head)
32 } else {
33 return new Range(other || head, head)
34 }
35}
36
37// Extend the primary selection range, discard the rest.
38export function extendSelection(doc, head, other, options, extend) {

Callers 3

leftButtonSelectFunction · 0.90
extendSelectionFunction · 0.70
extendSelectionsFunction · 0.70

Calls 1

cmpFunction · 0.90

Tested by

no test coverage detected