Fix error with detection position of cursor (fix #47)