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

Function adjustView

static/libs/codemirror.js:4016–4033  ·  view source on GitHub ↗
(cm, from, to)

Source from the content-addressed store, hash-verified

4014// Force the view to cover a given range, adding empty view element
4015// or clipping off existing ones as needed.
4016function adjustView(cm, from, to) {
4017 var display = cm.display, view = display.view;
4018 if (view.length == 0 || from >= display.viewTo || to <= display.viewFrom) {
4019 display.view = buildViewArray(cm, from, to);
4020 display.viewFrom = from;
4021 } else {
4022 if (display.viewFrom > from)
4023 { display.view = buildViewArray(cm, from, display.viewFrom).concat(display.view); }
4024 else if (display.viewFrom < from)
4025 { display.view = display.view.slice(findViewIndex(cm, from)); }
4026 display.viewFrom = from;
4027 if (display.viewTo < to)
4028 { display.view = display.view.concat(buildViewArray(cm, display.viewTo, to)); }
4029 else if (display.viewTo > to)
4030 { display.view = display.view.slice(0, findViewIndex(cm, to)); }
4031 }
4032 display.viewTo = to;
4033}
4034
4035// Count the number of lines in the view whose DOM representation is
4036// out of date (or nonexistent).

Callers 1

updateDisplayIfNeededFunction · 0.85

Calls 2

buildViewArrayFunction · 0.85
findViewIndexFunction · 0.85

Tested by

no test coverage detected