[Azoth Rosenthal] Properly detect word under cursor.

Fixes #1716.