Check cursor point to avoid inserting extraneous text

(hopefully) fixes #59