dthree / vorpal

Node's framework for interactive CLIs
http://vorpal.js.org
MIT License
5.64k stars 280 forks source link

Problems with slashes in autocomplete options #124

Open devinus opened 8 years ago

devinus commented 8 years ago

Using these options: ['a/b', 'a/boo', 'b/a', 'b/c']

-> % node cli.js
local@cutter~$ send a/b/
a/b  a/boo  b/a  b/c
local@cutter~$ send a/b/

It wont autocomplete the whole string and it's just funky in general. Not how I would expect autocomplete to work.

enriched commented 8 years ago

👍 I am experiencing this using callback based autocomplete

bilbercode commented 8 years ago

I have also experienced this issue, I resolved by returning only the post suffix options so the autocomplete would function correctly.

for example


function autocompleteResponse(input, cb) {

   // Autocomplete options logic...
   return cb([
     "b",
     "boo",
     "a",
     "c"
   ]);

}

There is also a bug relating to when the user inputs $ foo/b with the given options of ["baz", "bang"] in that the autocomplete resolution craps out a little and removes the prefix foo from the result.

I have made a pull request to get this fixed, as well as some minor related ;)

robross0606 commented 1 year ago

This still appears to be a problem specifically if the auto-complete returns a single item that has a slash in it.