Handle search term properly when widget is open

fixes #319

Now the behaviour is identical whether the search widget is open
or not:

a) No search term
-> word at cursor is search term (if selected or not)

b) Existing search term
-> 1) No selection in document
      Search term is kept but selected
   2) Selection in document
      Selection is new search term