(pos)
| 3714 | |
| 3715 | var lastPos = start; |
| 3716 | function extendTo(pos) { |
| 3717 | if (cmp(lastPos, pos) == 0) return; |
| 3718 | lastPos = pos; |
| 3719 | |
| 3720 | if (type == "rect") { |
| 3721 | var ranges = [], tabSize = cm.options.tabSize; |
| 3722 | var startCol = countColumn(getLine(doc, start.line).text, start.ch, tabSize); |
| 3723 | var posCol = countColumn(getLine(doc, pos.line).text, pos.ch, tabSize); |
| 3724 | var left = Math.min(startCol, posCol), right = Math.max(startCol, posCol); |
| 3725 | for (var line = Math.min(start.line, pos.line), end = Math.min(cm.lastLine(), Math.max(start.line, pos.line)); |
| 3726 | line <= end; line++) { |
| 3727 | var text = getLine(doc, line).text, leftPos = findColumn(text, left, tabSize); |
| 3728 | if (left == right) |
| 3729 | ranges.push(new Range(Pos(line, leftPos), Pos(line, leftPos))); |
| 3730 | else if (text.length > leftPos) |
| 3731 | ranges.push(new Range(Pos(line, leftPos), Pos(line, findColumn(text, right, tabSize)))); |
| 3732 | } |
| 3733 | if (!ranges.length) ranges.push(new Range(start, start)); |
| 3734 | setSelection(doc, normalizeSelection(startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex), |
| 3735 | {origin: "*mouse", scroll: false}); |
| 3736 | cm.scrollIntoView(pos); |
| 3737 | } else { |
| 3738 | var oldRange = ourRange; |
| 3739 | var anchor = oldRange.anchor, head = pos; |
| 3740 | if (type != "single") { |
| 3741 | if (type == "double") |
| 3742 | var range = cm.findWordAt(pos); |
| 3743 | else |
| 3744 | var range = new Range(Pos(pos.line, 0), clipPos(doc, Pos(pos.line + 1, 0))); |
| 3745 | if (cmp(range.anchor, anchor) > 0) { |
| 3746 | head = range.head; |
| 3747 | anchor = minPos(oldRange.from(), range.anchor); |
| 3748 | } else { |
| 3749 | head = range.anchor; |
| 3750 | anchor = maxPos(oldRange.to(), range.head); |
| 3751 | } |
| 3752 | } |
| 3753 | var ranges = startSel.ranges.slice(0); |
| 3754 | ranges[ourIndex] = new Range(clipPos(doc, anchor), head); |
| 3755 | setSelection(doc, normalizeSelection(ranges, ourIndex), sel_mouse); |
| 3756 | } |
| 3757 | } |
| 3758 | |
| 3759 | var editorSize = display.wrapper.getBoundingClientRect(); |
| 3760 | // Used to ensure timeout re-tries don't fire when another extend |
no test coverage detected