repl: fix 'ERROR: key not found: nothing' reverse-i-search bug

Part of #6325.