Skip to content
Permalink
Browse files

readline: emit key info unconditionally

Currently, 'keypress' events include the sequence and key info
for named keys, but only the sequence for unnamed keys. This
commit causes the key info to be included in both cases.

PR-URL: #6024
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
  • Loading branch information...
cjihrig committed Apr 3, 2016
1 parent 3de9bc9 commit 0a62f929da0cff816d79d2ed2b9b3b4ecdd50586
Showing with 3 additions and 4 deletions.
  1. +2 −3 lib/internal/readline.js
  2. +1 −1 test/parallel/test-readline-keys.js
@@ -384,9 +384,8 @@ function* emitKeys(stream) {
stream.emit('keypress', escaped ? undefined : s, key);
} else if (s.length === 1) {
/* Single unnamed character, e.g. "." */
stream.emit('keypress', s);
} else {
/* Unrecognized or broken escape sequence, don't emit anything */
stream.emit('keypress', s, key);
}
/* Unrecognized or broken escape sequence, don't emit anything */
}
}
@@ -48,7 +48,7 @@ function addTest(sequences, expectedKeys) {
addTest('io.JS', [
{ name: 'i', sequence: 'i' },
{ name: 'o', sequence: 'o' },
undefined, // emitted as `emit('keypress', '.', undefined)`
{ name: undefined, sequence: '.' },
{ name: 'j', sequence: 'J', shift: true },
{ name: 's', sequence: 'S', shift: true },
]);

0 comments on commit 0a62f92

Please sign in to comment.
You can’t perform that action at this time.