Improve search field behaviour

For details see commit messages and #319.

I think after this one should do something similar for replace.