fix caret state updating bug