MCPcopy Create free account
hub / github.com/TextGeneratorio/text-generator.io / maybeUpdateLineNumberWidth

Function maybeUpdateLineNumberWidth

static/libs/codemirror.js:3334–3350  ·  view source on GitHub ↗
(cm)

Source from the content-addressed store, hash-verified

3332// size for the current document size. Returns true when an update
3333// is needed.
3334function maybeUpdateLineNumberWidth(cm) {
3335 if (!cm.options.lineNumbers) { return false }
3336 var doc = cm.doc, last = lineNumberFor(cm.options, doc.first + doc.size - 1), display = cm.display;
3337 if (last.length != display.lineNumChars) {
3338 var test = display.measure.appendChild(elt("div", [elt("div", last)],
3339 "CodeMirror-linenumber CodeMirror-gutter-elt"));
3340 var innerW = test.firstChild.offsetWidth, padding = test.offsetWidth - innerW;
3341 display.lineGutter.style.width = "";
3342 display.lineNumInnerWidth = Math.max(innerW, display.lineGutter.offsetWidth - padding) + 1;
3343 display.lineNumWidth = display.lineNumInnerWidth + padding;
3344 display.lineNumChars = display.lineNumInnerWidth ? last.length : -1;
3345 display.lineGutter.style.width = display.lineNumWidth + "px";
3346 updateGutterSpace(cm);
3347 return true
3348 }
3349 return false
3350}
3351
3352// SCROLLING THINGS INTO VIEW
3353

Callers 2

updateDisplayIfNeededFunction · 0.85
CodeMirror$1Function · 0.85

Calls 3

lineNumberForFunction · 0.85
eltFunction · 0.85
updateGutterSpaceFunction · 0.85

Tested by

no test coverage detected