(range, head, other, extend)
| 17 | // Otherwise, simply returns the range between the given positions. |
| 18 | // Used for cursor motion and such. |
| 19 | export 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. |
| 38 | export function extendSelection(doc, head, other, options, extend) { |
no test coverage detected