Also set text selection end, if it is valid. Fixes #324.