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

Function maybeUpdateLineNumberWidth

external/.scrollLibs.js:4814–4834  ·  view source on GitHub ↗
(cm)

Source from the content-addressed store, hash-verified

4812 // size for the current document size. Returns true when an update
4813 // is needed.
4814 function maybeUpdateLineNumberWidth(cm) {
4815 if (!cm.options.lineNumbers) {
4816 return false
4817 }
4818 var doc = cm.doc,
4819 last = lineNumberFor(cm.options, doc.first + doc.size - 1),
4820 display = cm.display
4821 if (last.length != display.lineNumChars) {
4822 var test = display.measure.appendChild(elt("div", [elt("div", last)], "CodeMirror-linenumber CodeMirror-gutter-elt"))
4823 var innerW = test.firstChild.offsetWidth,
4824 padding = test.offsetWidth - innerW
4825 display.lineGutter.style.width = ""
4826 display.lineNumInnerWidth = Math.max(innerW, display.lineGutter.offsetWidth - padding) + 1
4827 display.lineNumWidth = display.lineNumInnerWidth + padding
4828 display.lineNumChars = display.lineNumInnerWidth ? last.length : -1
4829 display.lineGutter.style.width = display.lineNumWidth + "px"
4830 updateGutterSpace(cm)
4831 return true
4832 }
4833 return false
4834 }
4835
4836 // SCROLLING THINGS INTO VIEW
4837

Callers 2

updateDisplayIfNeededFunction · 0.85
CodeMirrorFunction · 0.85

Calls 4

lineNumberForFunction · 0.85
eltFunction · 0.85
updateGutterSpaceFunction · 0.85
maxMethod · 0.80

Tested by

no test coverage detected