MCPcopy
hub / github.com/HubSpot/messenger / patchDisplay

Function patchDisplay

docs/welcome/lib/executr/lib/CodeMirror/codemirror.js:557–607  ·  view source on GitHub ↗
(cm, from, to, intact, updateNumbersFrom)

Source from the content-addressed store, hash-verified

555 }
556
557 function patchDisplay(cm, from, to, intact, updateNumbersFrom) {
558 var dims = getDimensions(cm);
559 var display = cm.display, lineNumbers = cm.options.lineNumbers;
560 if (!intact.length && (!webkit || !cm.display.currentWheelTarget))
561 removeChildren(display.lineDiv);
562 var container = display.lineDiv, cur = container.firstChild;
563
564 function rm(node) {
565 var next = node.nextSibling;
566 if (webkit && mac && cm.display.currentWheelTarget == node) {
567 node.style.display = "none";
568 node.lineObj = null;
569 } else {
570 node.parentNode.removeChild(node);
571 }
572 return next;
573 }
574
575 var nextIntact = intact.shift(), lineNo = from;
576 cm.view.doc.iter(from, to, function(line) {
577 if (nextIntact && nextIntact.to == lineNo) nextIntact = intact.shift();
578 if (lineIsHidden(line)) {
579 if (line.height != 0) updateLineHeight(line, 0);
580 if (line.widgets && cur.previousSibling) for (var i = 0; i < line.widgets.length; ++i)
581 if (line.widgets[i].showIfHidden) {
582 var prev = cur.previousSibling;
583 if (prev.nodeType == "pre") {
584 var wrap = elt("div", null, null, "position: relative");
585 prev.parentNode.replaceChild(wrap, prev);
586 wrap.appendChild(prev);
587 prev = wrap;
588 }
589 prev.appendChild(buildLineWidget(line.widgets[i], prev, dims));
590 }
591 } else if (nextIntact && nextIntact.from <= lineNo && nextIntact.to > lineNo) {
592 // This line is intact. Skip to the actual node. Update its
593 // line number if needed.
594 while (cur.lineObj != line) cur = rm(cur);
595 if (lineNumbers && updateNumbersFrom <= lineNo && cur.lineNumber)
596 setTextContent(cur.lineNumber, lineNumberFor(cm.options, lineNo));
597 cur = cur.nextSibling;
598 } else {
599 // This line needs to be generated.
600 var lineNode = buildLineElement(cm, line, lineNo, dims);
601 container.insertBefore(lineNode, cur);
602 lineNode.lineObj = line;
603 }
604 ++lineNo;
605 });
606 while (cur) cur = rm(cur);
607 }
608
609 function buildLineElement(cm, line, lineNo, dims) {
610 var lineElement = lineContent(cm, line);

Callers 1

updateDisplayInnerFunction · 0.85

Calls 10

getDimensionsFunction · 0.85
removeChildrenFunction · 0.85
lineIsHiddenFunction · 0.85
updateLineHeightFunction · 0.85
eltFunction · 0.85
buildLineWidgetFunction · 0.85
rmFunction · 0.85
setTextContentFunction · 0.85
lineNumberForFunction · 0.85
buildLineElementFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…