Fixed caret positioning