Fix bug #15973 with erratic cursor motion after reverting a buffer.