Fix bug with search history restoring