Keep number of cursor positions in a document identical regardless of annotation display

Rendering annotations causes the number of available cursor positions to be reduced by one. The original rule was added to stop the cursor getting in between the annotation highlight span and the annotation end. Rather than moving the valid cursor position to inside the span, this
simply removed the position entirely.

This patch adds additional logic to allow the cursor to stop just inside the annotation's highlight span so the number of positions in the doc stays consistent regardless of whether annotations are shown or not.

Incidentally, this also fixes issue #51.