Detect pending text insertion when inserting from hint list

This is for #5003.

CodeHintList now keeps  track of pending text insertions so it can make a better decision about when to insert when it receives an `Enter` key.