MCPcopy Create free account
hub / github.com/feiyu563/PrometheusAlert / patchDisplay

Function patchDisplay

static/plugins/codemirror/codemirror.js:4227–4266  ·  view source on GitHub ↗
(cm, updateNumbersFrom, dims)

Source from the content-addressed store, hash-verified

4225 // that are not there yet, and updating the ones that are out of
4226 // date.
4227 function patchDisplay(cm, updateNumbersFrom, dims) {
4228 var display = cm.display, lineNumbers = cm.options.lineNumbers;
4229 var container = display.lineDiv, cur = container.firstChild;
4230
4231 function rm(node) {
4232 var next = node.nextSibling;
4233 // Works around a throw-scroll bug in OS X Webkit
4234 if (webkit && mac && cm.display.currentWheelTarget == node)
4235 { node.style.display = "none"; }
4236 else
4237 { node.parentNode.removeChild(node); }
4238 return next
4239 }
4240
4241 var view = display.view, lineN = display.viewFrom;
4242 // Loop over the elements in the view, syncing cur (the DOM nodes
4243 // in display.lineDiv) with the view as we go.
4244 for (var i = 0; i < view.length; i++) {
4245 var lineView = view[i];
4246 if (lineView.hidden) ; else if (!lineView.node || lineView.node.parentNode != container) { // Not drawn yet
4247 var node = buildLineElement(cm, lineView, lineN, dims);
4248 container.insertBefore(node, cur);
4249 } else { // Already drawn
4250 while (cur != lineView.node) { cur = rm(cur); }
4251 var updateNumber = lineNumbers && updateNumbersFrom != null &&
4252 updateNumbersFrom <= lineN && lineView.lineNumber;
4253 if (lineView.changes) {
4254 if (indexOf(lineView.changes, "gutter") > -1) { updateNumber = false; }
4255 updateLineForChanges(cm, lineView, lineN, dims);
4256 }
4257 if (updateNumber) {
4258 removeChildren(lineView.lineNumber);
4259 lineView.lineNumber.appendChild(document.createTextNode(lineNumberFor(cm.options, lineN)));
4260 }
4261 cur = lineView.node.nextSibling;
4262 }
4263 lineN += lineView.size;
4264 }
4265 while (cur) { cur = rm(cur); }
4266 }
4267
4268 function updateGutterSpace(display) {
4269 var width = display.gutters.offsetWidth;

Callers 1

updateDisplayIfNeededFunction · 0.85

Calls 6

buildLineElementFunction · 0.85
updateLineForChangesFunction · 0.85
removeChildrenFunction · 0.85
lineNumberForFunction · 0.85
rmFunction · 0.70
indexOfFunction · 0.70

Tested by

no test coverage detected