Fix issue with invalid hint hiding after code was changed

This is for #7233
The code may not be the best, but I'm not used to promises.