Remove leading/trailing spaces from search string

Some keyboards insert a trailing space when doing word completion.
Merge remote-tracking branch 'upstream/master'