code: function patchDisplay(cm, updateNumbersFrom, dims) {
    let display = cm.display, lineNumbers = cm.options.lineNumbers
    let container = display.lineDiv, cur = container.firstChild
  
    function rm(node) {
      let next = node.nextSibling
      // Works around a throw-scroll bug in OS X Webkit
      if (webkit && mac && cm.display.currentWheelTarget == node)
        node.style.display = "none"
      else
        node.parentNode.removeChild(node)
      return next
    }
  
    let view = display.view, lineN = display.viewFrom
    // Loop over the elements in the view, syncing cur (the DOM nodes
    // in display.lineDiv) with the view as we go.
    for (let i = 0; i < view.length; i++) {
      let lineView = view[i]
      if (lineView.hidden) {
      } else if (!lineView.node || lineView.node.parentNode != container) { // Not drawn yet
        let node = buildLineElement(cm, lineView, lineN, dims)
        container.insertBefore(node, cur)
      } else { // Already drawn
        while (cur != lineView.node) cur = rm(cur)
        let updateNumber = lineNumbers && updateNumbersFrom != null &&
          updateNumbersFrom <= lineN && lineView.lineNumber
        if (lineView.changes) {
          if (indexOf(lineView.changes, "gutter") > -1) updateNumber = false
          updateLineForChanges(cm, lineView, lineN, dims)
        }
        if (updateNumber) {
          removeChildren(lineView.lineNumber)
          lineView.lineNumber.appendChild(document.createTextNode(lineNumberFor(cm.options, lineN)))
        }
        cur = lineView.node.nextSibling
      }
      lineN += lineView.size
    }
    while (cur) cur = rm(cur)
  }
docs: Sync the actual display DOM structure with display.view, removing nodes for lines that are no longer in view, and creating the ones that are not there yet, and updating the ones that are out of date.