This was the problem... cursor position was not taking account the partial word length.