MCPcopy Create free account
hub / github.com/breck7/scroll / prepareSelection

Function prepareSelection

external/.scrollLibs.js:4439–4464  ·  view source on GitHub ↗
(cm, primary)

Source from the content-addressed store, hash-verified

4437 }
4438
4439 function prepareSelection(cm, primary) {
4440 if (primary === void 0) primary = true
4441
4442 var doc = cm.doc,
4443 result = {}
4444 var curFragment = (result.cursors = document.createDocumentFragment())
4445 var selFragment = (result.selection = document.createDocumentFragment())
4446
4447 for (var i = 0; i < doc.sel.ranges.length; i++) {
4448 if (!primary && i == doc.sel.primIndex) {
4449 continue
4450 }
4451 var range$$1 = doc.sel.ranges[i]
4452 if (range$$1.from().line >= cm.display.viewTo || range$$1.to().line < cm.display.viewFrom) {
4453 continue
4454 }
4455 var collapsed = range$$1.empty()
4456 if (collapsed || cm.options.showCursorWhenSelecting) {
4457 drawSelectionCursor(cm, range$$1.head, curFragment)
4458 }
4459 if (!collapsed) {
4460 drawSelectionRange(cm, range$$1, selFragment)
4461 }
4462 }
4463 return result
4464 }
4465
4466 // Draws a cursor for the given range
4467 function drawSelectionCursor(cm, head, output) {

Callers 1

.scrollLibs.jsFile · 0.85

Calls 3

drawSelectionCursorFunction · 0.85
drawSelectionRangeFunction · 0.85
fromMethod · 0.45

Tested by

no test coverage detected