Fixes the text box cursor position.

The placement of the cursor sometimes was wrong under Windows. (The bug
could be reproduced under Linux by changing the configuration files.)

The problem was caused by the height of the text box and the permission
to wrap the text on a new line. This caused the cursor position to
return to the beginning of the line.

Fixes bug #17220 using patch #3822.

Cherry-picked from 9c80bf64c5317db2d465bdfbfad8dde625661e98