By this point, the "pending text" is being inserted asynchronously into the page by CodeMirror -- we're just trying to figure out what to do with `Enter` key. If we insert the first match into the page, CodeMirror still inserts the pending text into the page, so the pending text gets duplicated.