(pos)
| 3586 | |
| 3587 | var lastPos = start; |
| 3588 | function extendTo(pos) { |
| 3589 | if (cmp(lastPos, pos) == 0) return; |
| 3590 | lastPos = pos; |
| 3591 | |
| 3592 | if (type == "rect") { |
| 3593 | var ranges = [], tabSize = cm.options.tabSize; |
| 3594 | var startCol = countColumn(getLine(doc, start.line).text, start.ch, tabSize); |
| 3595 | var posCol = countColumn(getLine(doc, pos.line).text, pos.ch, tabSize); |
| 3596 | var left = Math.min(startCol, posCol), right = Math.max(startCol, posCol); |
| 3597 | for (var line = Math.min(start.line, pos.line), end = Math.min(cm.lastLine(), Math.max(start.line, pos.line)); |
| 3598 | line <= end; line++) { |
| 3599 | var text = getLine(doc, line).text, leftPos = findColumn(text, left, tabSize); |
| 3600 | if (left == right) |
| 3601 | ranges.push(new Range(Pos(line, leftPos), Pos(line, leftPos))); |
| 3602 | else if (text.length > leftPos) |
| 3603 | ranges.push(new Range(Pos(line, leftPos), Pos(line, findColumn(text, right, tabSize)))); |
| 3604 | } |
| 3605 | if (!ranges.length) ranges.push(new Range(start, start)); |
| 3606 | setSelection(doc, normalizeSelection(startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex), |
| 3607 | {origin: "*mouse", scroll: false}); |
| 3608 | cm.scrollIntoView(pos); |
| 3609 | } else { |
| 3610 | var oldRange = ourRange; |
| 3611 | var anchor = oldRange.anchor, head = pos; |
| 3612 | if (type != "single") { |
| 3613 | if (type == "double") |
| 3614 | var range = cm.findWordAt(pos); |
| 3615 | else |
| 3616 | var range = new Range(Pos(pos.line, 0), clipPos(doc, Pos(pos.line + 1, 0))); |
| 3617 | if (cmp(range.anchor, anchor) > 0) { |
| 3618 | head = range.head; |
| 3619 | anchor = minPos(oldRange.from(), range.anchor); |
| 3620 | } else { |
| 3621 | head = range.anchor; |
| 3622 | anchor = maxPos(oldRange.to(), range.head); |
| 3623 | } |
| 3624 | } |
| 3625 | var ranges = startSel.ranges.slice(0); |
| 3626 | ranges[ourIndex] = new Range(clipPos(doc, anchor), head); |
| 3627 | setSelection(doc, normalizeSelection(ranges, ourIndex), sel_mouse); |
| 3628 | } |
| 3629 | } |
| 3630 | |
| 3631 | var editorSize = display.wrapper.getBoundingClientRect(); |
| 3632 | // Used to ensure timeout re-tries don't fire when another extend |
no test coverage detected