Fix #138: Bugs in autocomplete.

* The regex demanded a non-empty prefix, causing errors in
  an empty field or after space.

* For commands, an undefined return value was turned into
  "/undefined".