(pos)
| 243 | |
| 244 | let lastPos = start |
| 245 | function extendTo(pos) { |
| 246 | if (cmp(lastPos, pos) == 0) return |
| 247 | lastPos = pos |
| 248 | |
| 249 | if (behavior.unit == "rectangle") { |
| 250 | let ranges = [], tabSize = cm.options.tabSize |
| 251 | let startCol = countColumn(getLine(doc, start.line).text, start.ch, tabSize) |
| 252 | let posCol = countColumn(getLine(doc, pos.line).text, pos.ch, tabSize) |
| 253 | let left = Math.min(startCol, posCol), right = Math.max(startCol, posCol) |
| 254 | for (let line = Math.min(start.line, pos.line), end = Math.min(cm.lastLine(), Math.max(start.line, pos.line)); |
| 255 | line <= end; line++) { |
| 256 | let text = getLine(doc, line).text, leftPos = findColumn(text, left, tabSize) |
| 257 | if (left == right) |
| 258 | ranges.push(new Range(Pos(line, leftPos), Pos(line, leftPos))) |
| 259 | else if (text.length > leftPos) |
| 260 | ranges.push(new Range(Pos(line, leftPos), Pos(line, findColumn(text, right, tabSize)))) |
| 261 | } |
| 262 | if (!ranges.length) ranges.push(new Range(start, start)) |
| 263 | setSelection(doc, normalizeSelection(cm, startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex), |
| 264 | {origin: "*mouse", scroll: false}) |
| 265 | cm.scrollIntoView(pos) |
| 266 | } else { |
| 267 | let oldRange = ourRange |
| 268 | let range = rangeForUnit(cm, pos, behavior.unit) |
| 269 | let anchor = oldRange.anchor, head |
| 270 | if (cmp(range.anchor, anchor) > 0) { |
| 271 | head = range.head |
| 272 | anchor = minPos(oldRange.from(), range.anchor) |
| 273 | } else { |
| 274 | head = range.anchor |
| 275 | anchor = maxPos(oldRange.to(), range.head) |
| 276 | } |
| 277 | let ranges = startSel.ranges.slice(0) |
| 278 | ranges[ourIndex] = bidiSimplify(cm, new Range(clipPos(doc, anchor), head)) |
| 279 | setSelection(doc, normalizeSelection(cm, ranges, ourIndex), sel_mouse) |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | let editorSize = display.wrapper.getBoundingClientRect() |
| 284 | // Used to ensure timeout re-tries don't fire when another extend |
no test coverage detected