Make sure there is a cursor before setting position

Fixes #13