mokkabonna / inquirer-autocomplete-prompt

Autocomplete prompt for inquirer
ISC License
350 stars 82 forks source link

Regarding initial search string as `null` #54

Closed ycmjason closed 6 years ago

ycmjason commented 6 years ago

Thank you very much for building this amazing tool!

I find it weird that the initial search string being passed to source is set to null. I think it would make more sense if '' is passed. Is there any philosophy behind this decision?

Would be happy to submit a pull request to change this.

ycmjason commented 6 years ago

Even passing undefined is better so that I could use default parameters for searchString. Now I have to do the old school searchString = searchString || '' in order to set it to ''.

mokkabonna commented 6 years ago

Null was chosen over '' so that you could determine if the user has typed something, then removed it (resulting in '' ) or if it was the first "search".

I agree that undefined is better.

mokkabonna commented 6 years ago

Open a PR if you like, will close #52 as well

ghost commented 6 years ago

Is it possible to pass in an array/list as default instead of initial null/undefined. Maybe it could be picked up from default or choices key from inquirer.

ycmjason commented 6 years ago

The idea of using undefined is that we could use function default args to set whatever default you want.