Fix substring history search