Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
export ESCAPE_CODE_TIMEOUT
  • Loading branch information
raoofha authored and refack committed Oct 16, 2018
commit 991174e3eedddf6c6381cd14776e86077d3d2d7f
8 changes: 3 additions & 5 deletions lib/readline.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ const lineEnding = /\r?\n|\r(?!\n)/;
const KEYPRESS_DECODER = Symbol('keypress-decoder');
const ESCAPE_DECODER = Symbol('escape-decoder');

// GNU readline library - keyseq-timeout is 500ms (default)
const ESCAPE_CODE_TIMEOUT = 500;

function createInterface(input, output, completer, terminal) {
return new Interface(input, output, completer, terminal);
}
Expand Down Expand Up @@ -1020,7 +1017,7 @@ function emitKeypressEvents(stream, iface) {
stream[ESCAPE_DECODER].next(r[i]);
// Escape letter at the tail position
if (r[i] === kEscape && i + 1 === r.length) {
timeoutId = setTimeout(escapeCodeTimeout, ESCAPE_CODE_TIMEOUT);
timeoutId = setTimeout(escapeCodeTimeout, module.exports.ESCAPE_CODE_TIMEOUT);
}
} catch (err) {
// if the generator throws (it could happen in the `keypress`
Expand Down Expand Up @@ -1139,5 +1136,6 @@ module.exports = {
createInterface,
cursorTo,
emitKeypressEvents,
moveCursor
moveCursor,
ESCAPE_CODE_TIMEOUT : 500 // GNU readline library - keyseq-timeout is 500ms (default)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're going to do this, passing escapeCodeTimeout as an option to readline.createInterface() would seem to be the better approach.

};