Fix trimming in autocomplete