mokkabonna / inquirer-autocomplete-prompt

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

"No results." on init? #12

Closed mhkeller closed 8 years ago

mhkeller commented 8 years ago

When I launch the example it displays "No results..." as opposed to showing me the list as it used to do. It works as expected in https://github.com/mokkabonna/inquirer-autocomplete-prompt/commit/e75ae50681cecfd2ba8c23f804f61f6abf26c663 but breaks as of https://github.com/mokkabonna/inquirer-autocomplete-prompt/commit/faf4a4c17ae8153e7b5ec6b10b525b9343d0651a. I tried looking through there to see what might have caused it but didn't see it right away.

mokkabonna commented 8 years ago

It is because of this I guess https://github.com/mokkabonna/inquirer-autocomplete-prompt/compare/e75ae50681cecfd2ba8c23f804f61f6abf26c663...faf4a4c17ae8153e7b5ec6b10b525b9343d0651a#diff-168726dbe96b3ce427e7fedce31bb0bcR66

Moving from undefined to null as first input. Shouldn't be a problem in real world usage though. It is just that the example use a simple matching logic and it seems that new RegExp behaves differently for the two values.

new RegExp(undefined, 'i')
//=> /(?:)/i
new RegExp(null, 'i')
//=> /null/i

You can choose to do whatever you want based on null.

mhkeller commented 8 years ago

I see. Maybe adding if (!input) return true to the example would make it nicer for folks to get up and running.