MCPcopy Index your code
hub / github.com/csev/py4e / maybeUpdateLineNumberWidth

Function maybeUpdateLineNumberWidth

tools/pythonauto/static/codemirrorepl/codemirror.js:497–513  ·  view source on GitHub ↗
(cm)

Source from the content-addressed store, hash-verified

495 // size for the current document size. Returns true when an update
496 // is needed.
497 function maybeUpdateLineNumberWidth(cm) {
498 if (!cm.options.lineNumbers) return false;
499 var doc = cm.doc, last = lineNumberFor(cm.options, doc.first + doc.size - 1), display = cm.display;
500 if (last.length != display.lineNumChars) {
501 var test = display.measure.appendChild(elt("div", [elt("div", last)],
502 "CodeMirror-linenumber CodeMirror-gutter-elt"));
503 var innerW = test.firstChild.offsetWidth, padding = test.offsetWidth - innerW;
504 display.lineGutter.style.width = "";
505 display.lineNumInnerWidth = Math.max(innerW, display.lineGutter.offsetWidth - padding);
506 display.lineNumWidth = display.lineNumInnerWidth + padding;
507 display.lineNumChars = display.lineNumInnerWidth ? last.length : -1;
508 display.lineGutter.style.width = display.lineNumWidth + "px";
509 updateGutterSpace(cm);
510 return true;
511 }
512 return false;
513 }
514
515 function lineNumberFor(options, i) {
516 return String(options.lineNumberFormatter(i + options.firstLineNumber));

Callers 1

updateDisplayInnerFunction · 0.70

Calls 4

updateGutterSpaceFunction · 0.85
lineNumberForFunction · 0.70
eltFunction · 0.70
appendChildMethod · 0.45

Tested by

no test coverage detected