-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
repl: don’t write to input stream in editor mode #9207
Conversation
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()`.
|
||
if (!checkTerminalCodes) { | ||
while (found.includes(terminalCode)) | ||
found = found.replace(terminalCode, ''); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 😄
There was a problem hiding this comment.
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
f536ac6
to
979528d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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 <princejohnwesley@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
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 <princejohnwesley@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
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 <princejohnwesley@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
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 <princejohnwesley@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
@addaleax lts? |
@thealphanerd v6.x only, but yes |
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 <princejohnwesley@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
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 <princejohnwesley@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Checklist
make -j8 test
(UNIX), orvcbuild test nosign
(Windows) passesAffected core subsystem(s)
repl
Description of change
.editor
mode,repl.write()
would have crashed when thekey
argument was not present, because the overwritten_ttyWrite
of REPLs doesn’t check for the absence of a second argument likereadline.write()
does.Since the docs indicate that the argument is optional, add a check paralleling the one in
readline.write()
.spaces in
.editor
mode, letreadline
handle the spacesproperly (echoing them using
_ttyWrite
and adding them to thecurrent line buffer).
Fixes: #9189