Fix bug in visibleLines

This caused a nonsensical viewport to be returned in some cases,
causing the editor to show up empty.