mokkabonna / inquirer-autocomplete-prompt

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

crashes on special keys #1

Closed derhuerst closed 9 years ago

derhuerst commented 9 years ago

Whenever I type something /[^A-Z]/i, it crashes with TypeError: Cannot read property 'name' of undefined.

mokkabonna commented 9 years ago

What's your code like? Do you mean you type /[^A-Z]/i or when you type any character matching that regex?

derhuerst commented 9 years ago

Any character matching that regex.

mokkabonna commented 9 years ago

Ok I just was unsure because you called them special keys.

How are you using the plugin? Does running the example.js work for you?

derhuerst commented 9 years ago

How are you using the plugin?

In a pretty similar way.

Does running the example.js work for you?

No. I get the same error.

TypeError: Cannot read property 'name' of undefined
    at Prompt.onKeypress (/Users/jannis/Web/inquirer-autocomplete-prompt/index.js:176:12)
    at AnonymousObserver.Rx.AnonymousObserver.AnonymousObserver.next (/Users/jannis/Web/inquirer-autocomplete-prompt/node_modules/inquirer/node_modules/rx-lite/rx.lite.js:1811:12)
    at AnonymousObserver.Rx.internals.AbstractObserver.AbstractObserver.onNext (/Users/jannis/Web/inquirer-autocomplete-prompt/node_modules/inquirer/node_modules/rx-lite/rx.lite.js:1743:35)
    at AnonymousObserver.tryCatcher (/Users/jannis/Web/inquirer-autocomplete-prompt/node_modules/inquirer/node_modules/rx-lite/rx.lite.js:537:29)
    at AutoDetachObserverPrototype.next (/Users/jannis/Web/inquirer-autocomplete-prompt/node_modules/inquirer/node_modules/rx-lite/rx.lite.js:5421:51)
    at AutoDetachObserver.Rx.internals.AbstractObserver.AbstractObserver.onNext (/Users/jannis/Web/inquirer-autocomplete-prompt/node_modules/inquirer/node_modules/rx-lite/rx.lite.js:1743:35)
    at AnonymousObserver._onNext (/Users/jannis/Web/inquirer-autocomplete-prompt/node_modules/inquirer/node_modules/rx-lite/rx.lite.js:4069:15)
    at AnonymousObserver.Rx.AnonymousObserver.AnonymousObserver.next (/Users/jannis/Web/inquirer-autocomplete-prompt/node_modules/inquirer/node_modules/rx-lite/rx.lite.js:1811:12)
    at AnonymousObserver.Rx.internals.AbstractObserver.AbstractObserver.onNext (/Users/jannis/Web/inquirer-autocomplete-prompt/node_modules/inquirer/node_modules/rx-lite/rx.lite.js:1743:35)
    at AnonymousObserver.tryCatcher (/Users/jannis/Web/inquirer-autocomplete-prompt/node_modules/inquirer/node_modules/rx-lite/rx.lite.js:537:29)

Actually, I found another bug. When I type arrow down, I get the following.

ReferenceError: readline is not defined
    at Prompt.onKeypress (/Users/jannis/Web/inquirer-autocomplete-prompt/index.js:181:5)
    at AnonymousObserver.Rx.AnonymousObserver.AnonymousObserver.next (/Users/jannis/Web/inquirer-autocomplete-prompt/node_modules/inquirer/node_modules/rx-lite/rx.lite.js:1811:12)
    at AnonymousObserver.Rx.internals.AbstractObserver.AbstractObserver.onNext (/Users/jannis/Web/inquirer-autocomplete-prompt/node_modules/inquirer/node_modules/rx-lite/rx.lite.js:1743:35)
    at AnonymousObserver.tryCatcher (/Users/jannis/Web/inquirer-autocomplete-prompt/node_modules/inquirer/node_modules/rx-lite/rx.lite.js:537:29)
    at AutoDetachObserverPrototype.next (/Users/jannis/Web/inquirer-autocomplete-prompt/node_modules/inquirer/node_modules/rx-lite/rx.lite.js:5421:51)
    at AutoDetachObserver.Rx.internals.AbstractObserver.AbstractObserver.onNext (/Users/jannis/Web/inquirer-autocomplete-prompt/node_modules/inquirer/node_modules/rx-lite/rx.lite.js:1743:35)
    at AnonymousObserver._onNext (/Users/jannis/Web/inquirer-autocomplete-prompt/node_modules/inquirer/node_modules/rx-lite/rx.lite.js:4069:15)
    at AnonymousObserver.Rx.AnonymousObserver.AnonymousObserver.next (/Users/jannis/Web/inquirer-autocomplete-prompt/node_modules/inquirer/node_modules/rx-lite/rx.lite.js:1811:12)
    at AnonymousObserver.Rx.internals.AbstractObserver.AbstractObserver.onNext (/Users/jannis/Web/inquirer-autocomplete-prompt/node_modules/inquirer/node_modules/rx-lite/rx.lite.js:1743:35)
    at AnonymousObserver.tryCatcher (/Users/jannis/Web/inquirer-autocomplete-prompt/node_modules/inquirer/node_modules/rx-lite/rx.lite.js:537:29)
mhkeller commented 9 years ago

Actually I'm seeing this too. It happens with < > / [ ] \ ; ' and . Maybe it's a bug in thereadline` library.

readline.js:913
          stream[ESCAPE_DECODER].next(r[i]);
                                 ^
TypeError: Cannot read property 'name' of undefined
    at Prompt.onKeypress (/Users/mike/wrk/code/inquirer-autocomplete-prompt/index.js:184:12)
    at AnonymousObserver.Rx.AnonymousObserver.AnonymousObserver.next (/Users/mike/wrk/code/inquirer-autocomplete-prompt/node_modules/inquirer/node_modules/rx-lite/rx.lite.js:1811:12)
    at AnonymousObserver.Rx.internals.AbstractObserver.AbstractObserver.onNext (/Users/mike/wrk/code/inquirer-autocomplete-prompt/node_modules/inquirer/node_modules/rx-lite/rx.lite.js:1743:35)
    at AnonymousObserver.tryCatcher (/Users/mike/wrk/code/inquirer-autocomplete-prompt/node_modules/inquirer/node_modules/rx-lite/rx.lite.js:537:29)
    at AutoDetachObserverPrototype.next (/Users/mike/wrk/code/inquirer-autocomplete-prompt/node_modules/inquirer/node_modules/rx-lite/rx.lite.js:5421:51)
    at AutoDetachObserver.Rx.internals.AbstractObserver.AbstractObserver.onNext (/Users/mike/wrk/code/inquirer-autocomplete-prompt/node_modules/inquirer/node_modules/rx-lite/rx.lite.js:1743:35)
    at AnonymousObserver._onNext (/Users/mike/wrk/code/inquirer-autocomplete-prompt/node_modules/inquirer/node_modules/rx-lite/rx.lite.js:4069:15)
    at AnonymousObserver.Rx.AnonymousObserver.AnonymousObserver.next (/Users/mike/wrk/code/inquirer-autocomplete-prompt/node_modules/inquirer/node_modules/rx-lite/rx.lite.js:1811:12)
    at AnonymousObserver.Rx.internals.AbstractObserver.AbstractObserver.onNext (/Users/mike/wrk/code/inquirer-autocomplete-prompt/node_modules/inquirer/node_modules/rx-lite/rx.lite.js:1743:35)
    at AnonymousObserver.tryCatcher (/Users/mike/wrk/code/inquirer-autocomplete-prompt/node_modules/inquirer/node_modules/rx-lite/rx.lite.js:537:29)
mhkeller commented 9 years ago

Seeing this on iojs 2.3 as well as after updating to the latest, 4.2.2

mhkeller commented 9 years ago

Just tested it on the basic readline example and that worked fine with those characters https://nodejs.org/api/readline.html

mokkabonna commented 9 years ago

Fixed. was not so familiar with the event here and assumed all events had a e.key. But for instance when typing / it produced the following event: { value: '/', key: undefined }

derhuerst commented 9 years ago

Can you publish this package to npm so i can use it?

mokkabonna commented 9 years ago

Done. https://www.npmjs.com/package/inquirer-autocomplete-prompt

I have kept a 0.X version for now, want to get proper testcases etc before giving it the 1.0.0

Still, should work as expected.

derhuerst commented 9 years ago

Thanks a lot!