Improve caret positioning when dragging