editor: more intuitive cursor positioning

Compute the nearest glyph edge instead of taking the one to the
left of the cursor.

Also fixes a segfault when trying to compute the position for an empty
buffer.
1 file changed