Cursor position fix in history