Fix caret moving to start/end when pressing up/down