This code opens up new prompt every time a character is typed without closing the old one. It'd be better to update it to open a new prompt only if a query is looked up from the history buffer.

You can update `showPrompt` to return a function that closes the prompt. It's supported by the `dialog.js` extension. You'd just have to pass it through.