Wouldn't it be easier to just check positions, using `editor._codeMirror.cursorCoords().top`. If that doesn't work and you still need to use the line count, you shouldn't remove the word wrap, since unwrapping very long lines, might make the current line be above the bottom panel where before it wasn't. There is also an issue with different font sizes where the editor height is not what it should be (#3115), check how the first and last visible lines are calculated in Scroll line inside `ViewCommandHandlers` to get an idea of how to solve that.