Ignore garbage characters at the end of the current text selection