Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: readline.emitKeypressEvents note #9447

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
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
6 changes: 5 additions & 1 deletion doc/api/readline.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ rl.question('What do you think of Node.js? ', (answer) => {
});
```

*Note* Once this code is invoked, the Node.js application will not
*Note*: Once this code is invoked, the Node.js application will not
terminate until the `readline.Interface` is closed because the interface
waits for data to be received on the `input` stream.

Expand Down Expand Up @@ -447,6 +447,10 @@ autocompletion is disabled when copy-pasted input is detected.

If the `stream` is a [TTY][], then it must be in raw mode.

*Note*: This is automatically called by any readline instance on its `input`
Copy link
Contributor

Choose a reason for hiding this comment

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

Note after code snippet ?

if the `input` is a terminal. Closing the `readline` instance does not stop
Copy link
Contributor

Choose a reason for hiding this comment

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

@Trott Sounds like a bug to me.

  function onNewListener(event) {
    if (event == 'keypress') {
      stream.on('data', onData);
     // +++++++++ MISSING +++++++++++
      iface.once('close', () => {
        stream.removeListener('data', onData);
      });
     // +++++++++++++++++++++++++++++
      stream.removeListener('newListener', onNewListener);
    }
  }

Copy link
Member

Choose a reason for hiding this comment

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

Ping @Trott @princejwesley ... any further thoughts on this?

Copy link
Member

Choose a reason for hiding this comment

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

Not sure why I I'm being pinged on this (as opposed to anybody else) to be honest...

Copy link
Member

Choose a reason for hiding this comment

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

(Also not sure who a good person to ping about it would be, though. ¯\(ツ)/¯ )

Copy link
Member

Choose a reason for hiding this comment

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

(Also not sure who a good person to ping about it would be, though. ¯\(ツ)/¯ )

I think with hindsight we can say @addaleax would be a good person to ping 😉

Copy link
Member

Choose a reason for hiding this comment

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

Well … what I remember about these parts of the code mostly comes from reviewing ae17883, and that was a year ago. I guess at this point we don’t have any real readline experts…

the `input` from emitting `'keypress'` events.

```js
readline.emitKeypressEvents(process.stdin);
if (process.stdin.isTTY)
Expand Down