fixed a bug, when the value ends with a mention and the caret is at the end of it