Skip to content

readline: splitted escape sequences are processed incorrectly #1403

@rlidwka

Description

@rlidwka

I'm running io.js inside LXC container console (lxc-console) in Ubuntu 14.04 terminal.

When I press and hold an arrow key, node.js sometimes receives escape sequences splitted into multiple chunks:

$ node -e 'process.stdin.setRawMode(true);process.stdin.on("data", function(d){console.log(d)})'
<Buffer 1b 5b 44>
<Buffer 1b 5b 44>
<Buffer 1b>
<Buffer 5b 44>
<Buffer 1b 5b 44>

Here you can see \x1b[D (arrow left) is broken into \x1b + [D.

Readline doesn't handle those, because it assumes that the entire escape sequence is contained within a data chunk. So it skips escape character itself, and [D is getting printed to the terminal:

$ node
> console.log('h[Dello world')

Here is a screenshot.

Trying to find a way to fix it at the moment. Any ideas?

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.readlineIssues and PRs related to the built-in readline module.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions