fixed a bug when caret is directly before a mention, fixed a bug when using browser undo/redo