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

Function adjustView

external/.scrollLibs.js:5721–5741  ·  view source on GitHub ↗
(cm, from, to)

Source from the content-addressed store, hash-verified

5719 // Force the view to cover a given range, adding empty view element
5720 // or clipping off existing ones as needed.
5721 function adjustView(cm, from, to) {
5722 var display = cm.display,
5723 view = display.view
5724 if (view.length == 0 || from >= display.viewTo || to <= display.viewFrom) {
5725 display.view = buildViewArray(cm, from, to)
5726 display.viewFrom = from
5727 } else {
5728 if (display.viewFrom > from) {
5729 display.view = buildViewArray(cm, from, display.viewFrom).concat(display.view)
5730 } else if (display.viewFrom < from) {
5731 display.view = display.view.slice(findViewIndex(cm, from))
5732 }
5733 display.viewFrom = from
5734 if (display.viewTo < to) {
5735 display.view = display.view.concat(buildViewArray(cm, display.viewTo, to))
5736 } else if (display.viewTo > to) {
5737 display.view = display.view.slice(0, findViewIndex(cm, to))
5738 }
5739 }
5740 display.viewTo = to
5741 }
5742
5743 // Count the number of lines in the view whose DOM representation is
5744 // out of date (or nonexistent).

Callers 1

updateDisplayIfNeededFunction · 0.85

Calls 4

buildViewArrayFunction · 0.85
findViewIndexFunction · 0.85
concatMethod · 0.80
sliceMethod · 0.80

Tested by

no test coverage detected