Skip to content

Conversation

@addaleax
Copy link
Member

Checklist
  • make -j8 test (UNIX), or vcbuild test nosign (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

repl

Description of change
  • In .editor mode, repl.write() would have crashed when the key argument was not present, because the overwritten _ttyWrite of REPLs doesn’t check for the absence of a second argument like readline.write() does.
    Since the docs indicate that the argument is optional, add a check paralleling the one in readline.write().
  • Instead of writing to the REPL’s input stream for the alignment
    spaces in .editor mode, let readline handle the spaces
    properly (echoing them using _ttyWrite and adding them to the
    current line buffer).

Fixes: #9189

In `.editor` mode, `repl.write()` would have crashed when the `key` argument was not present, because the overwritten `_ttyWrite` of REPLs doesn’t check for the absence of a second argument like `readline.write()` does. Since the docs indicate that the argument is optional, add a check paralleling the one in `readline.write()`.
@nodejs-github-botnodejs-github-bot added the repl Issues and PRs related to the REPL subsystem. label Oct 20, 2016
@addaleax
Copy link
MemberAuthor

Copy link
Contributor

Choose a reason for hiding this comment

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

@addaleax quoted terminal code is sufficient right?
const terminalCodeRegex = /\u001b\[1G\u001b\[0J> \u001b\[3G/g

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

@princejwesley Yeah, I’ve updated it to use a regex… I’m not particularly a fan of duplicating strings that are hard to scan, but if you prefer a plain regex literal over what I’ve just pushed, I can go with that too

Copy link
Contributor

Choose a reason for hiding this comment

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

@addaleax 👍 Just to convey the term 'quoted' correctly, added code snippet with [ escaped manually 😄

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

@princejwesley ok, seems like we’re on the same page then 😄

Instead of writing to the REPL’s input stream for the alignment spaces in `.editor` mode, let `readline` handle the spaces properly (echoing them using `_ttyWrite` and adding them to the current line buffer). Fixes: nodejs#9189
@addaleaxaddaleaxforce-pushed the fix-repl-write-editor-mode branch from f536ac6 to 979528dCompareOctober 20, 2016 15:28
Copy link
Contributor

@princejwesleyprincejwesley left a comment

Choose a reason for hiding this comment

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

LGTM

@addaleax
Copy link
MemberAuthor

Landed in 8b6fd43 and 3dfc127

addaleax added a commit that referenced this pull request Oct 26, 2016
In `.editor` mode, `repl.write()` would have crashed when the `key` argument was not present, because the overwritten `_ttyWrite` of REPLs doesn’t check for the absence of a second argument like `readline.write()` does. Since the docs indicate that the argument is optional, add a check paralleling the one in `readline.write()`. PR-URL: #9207 Reviewed-By: Prince John Wesley <[email protected]> Reviewed-By: James M Snell <[email protected]>
addaleax added a commit that referenced this pull request Oct 26, 2016
Instead of writing to the REPL’s input stream for the alignment spaces in `.editor` mode, let `readline` handle the spaces properly (echoing them using `_ttyWrite` and adding them to the current line buffer). Fixes: #9189 PR-URL: #9207 Reviewed-By: Prince John Wesley <[email protected]> Reviewed-By: James M Snell <[email protected]>
@addaleaxaddaleax deleted the fix-repl-write-editor-mode branch October 26, 2016 19:49
evanlucas pushed a commit that referenced this pull request Nov 3, 2016
In `.editor` mode, `repl.write()` would have crashed when the `key` argument was not present, because the overwritten `_ttyWrite` of REPLs doesn’t check for the absence of a second argument like `readline.write()` does. Since the docs indicate that the argument is optional, add a check paralleling the one in `readline.write()`. PR-URL: #9207 Reviewed-By: Prince John Wesley <[email protected]> Reviewed-By: James M Snell <[email protected]>
evanlucas pushed a commit that referenced this pull request Nov 3, 2016
Instead of writing to the REPL’s input stream for the alignment spaces in `.editor` mode, let `readline` handle the spaces properly (echoing them using `_ttyWrite` and adding them to the current line buffer). Fixes: #9189 PR-URL: #9207 Reviewed-By: Prince John Wesley <[email protected]> Reviewed-By: James M Snell <[email protected]>
@evanlucasevanlucas mentioned this pull request Nov 3, 2016
@MylesBorins
Copy link
Contributor

@addaleax lts?

@addaleax
Copy link
MemberAuthor

@thealphanerd v6.x only, but yes

MylesBorins pushed a commit that referenced this pull request Nov 22, 2016
In `.editor` mode, `repl.write()` would have crashed when the `key` argument was not present, because the overwritten `_ttyWrite` of REPLs doesn’t check for the absence of a second argument like `readline.write()` does. Since the docs indicate that the argument is optional, add a check paralleling the one in `readline.write()`. PR-URL: #9207 Reviewed-By: Prince John Wesley <[email protected]> Reviewed-By: James M Snell <[email protected]>
MylesBorins pushed a commit that referenced this pull request Nov 22, 2016
Instead of writing to the REPL’s input stream for the alignment spaces in `.editor` mode, let `readline` handle the spaces properly (echoing them using `_ttyWrite` and adding them to the current line buffer). Fixes: #9189 PR-URL: #9207 Reviewed-By: Prince John Wesley <[email protected]> Reviewed-By: James M Snell <[email protected]>
@MylesBorinsMylesBorins mentioned this pull request Nov 22, 2016
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

replIssues and PRs related to the REPL subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@addaleax@MylesBorins@jasnell@princejwesley@nodejs-github-bot