Fix broken double-checking of display coverage

Both a potential infinite loop, due to updateDisplayIfNeeded not using
the updated set of visibile lines, and the fact that the current check
wasn't really covering changing document size, due to it happening before
the call to setDocumentHeight

Issue #2683