Improve autocomplete logic to handle special cases with whitespaces in hints