@njx, FYI, `cm.getViewport()` has too large of a range.  It gives the lines that are rendered, which is bigger than what is displayed.  I checked this for a file that displays lines 118-169 and it returns 95-176.  I'm looking for something more narrow.