fixes to completion behaviour

- if the result list is empty, end completion
- add the completion menu right before the last whitespace on the left
  of the cursor