Fix historyIndex to actually get the last command on key-up