Fix for autocomplete delete action removing only the last item

As reported at the bottom of #887