Multiple input history
Based on initial patch by Romain Francoise. I had actually committed his
patch in a branch, but some bits of the implementation looked a bit more
complicated than necessary. So I scratched that for this, which looks
pretty similar, but I think is a bit simpler to understand. The
behaviour is mostly the same, e.g. duplicate commands are moved at the
beginning of the history, and not added again.
There is currently no limit to the number of inputs to save in history.
But it can certainly be added if necessary.
Fixes #25074.