WIP: Fix issues highlighting lines containing the cursor

This PR is in progress, and aims to fix #2701.