MCPcopy
hub / github.com/witheve/Eve / visibleLines

Function visibleLines

src/codemirror.js:564–583  ·  view source on GitHub ↗
(display, doc, viewport)

Source from the content-addressed store, hash-verified

562 // the the current scroll position). viewport may contain top,
563 // height, and ensure (see op.scrollToPos) properties.
564 function visibleLines(display, doc, viewport) {
565 var top = viewport && viewport.top != null ? Math.max(0, viewport.top) : display.scroller.scrollTop;
566 top = Math.floor(top - paddingTop(display));
567 var bottom = viewport && viewport.bottom != null ? viewport.bottom : top + display.wrapper.clientHeight;
568
569 var from = lineAtHeight(doc, top), to = lineAtHeight(doc, bottom);
570 // Ensure is a {from: {line, ch}, to: {line, ch}} object, and
571 // forces those lines into the viewport (if possible).
572 if (viewport && viewport.ensure) {
573 var ensureFrom = viewport.ensure.from.line, ensureTo = viewport.ensure.to.line;
574 if (ensureFrom < from) {
575 from = ensureFrom;
576 to = lineAtHeight(doc, heightAtLine(getLine(doc, ensureFrom)) + display.wrapper.clientHeight);
577 } else if (Math.min(ensureTo, doc.lastLine()) >= to) {
578 from = lineAtHeight(doc, heightAtLine(getLine(doc, ensureTo)) - display.wrapper.clientHeight);
579 to = ensureTo;
580 }
581 }
582 return {from: from, to: Math.max(to, from + 1)};
583 }
584
585 // LINE NUMBERS
586

Callers 3

DisplayUpdateFunction · 0.85
postUpdateDisplayFunction · 0.85
extendFunction · 0.85

Calls 5

paddingTopFunction · 0.85
lineAtHeightFunction · 0.85
heightAtLineFunction · 0.85
getLineFunction · 0.85
lastLineMethod · 0.80

Tested by

no test coverage detected