add escapeCodeTimeout as an option to createInterface#19780
add escapeCodeTimeout as an option to createInterface#19780raoofha wants to merge 6 commits intonodejs:masterfrom
Conversation
|
Hi, @raoofha and welcome! Thanks for the pull request! Some immediate thoughts:
/ping @thlorenz |
|
Would it make sense to do this on a per-instance basis, rather than for each Node.js process as a whole? |
lib/readline.js
Outdated
There was a problem hiding this comment.
If we're going to do this, passing escapeCodeTimeout as an option to readline.createInterface() would seem to be the better approach.
|
I add doc ( copyed from here ) and manually test it on my machine. I don't know how to write test for it, if you can tell me how maybe I can do it. thanks |
|
Sorry @raoofha, I should have included this link with my comment! https://github.com/nodejs/node/blob/master/doc/guides/writing-tests.md Hope it helps. (And if it doesn't, maybe you can give some feedback and we can try to improve it!) |
|
thanks @Trott for your comments. I added a simple test and waiting for your review. |
|
I rebased to get rid of the conflict, and also reworded the documentation. (Hope that's OK!) |
|
CI failures are unrelated. Re-running relevant jobs. Re-run FreeBSD: https://ci.nodejs.org/job/node-test-commit-freebsd/16720/ |
lib/readline.js
Outdated
There was a problem hiding this comment.
Suggestion: the check could be moved in the upper if.
lib/readline.js
Outdated
There was a problem hiding this comment.
Suggestion: just write:
timeoutId = setTimeout(escapeCodeTimeoutFn, iface ? iface.escapeCodeTimeout : ESCAPE_CODE_TIMEOUT);
doc/api/readline.md
Outdated
There was a problem hiding this comment.
It is unclear in what unit the time is measured here. It should say something like The duration readline will wait for a character when reading an ambiguous key sequence in milliseconds (...).
I personally would also only accept integers but that is just me.
There was a problem hiding this comment.
These tests are doing all the same thing and are just duplicated. It would be best to write:
[
null,
{},
NaN,
'50'
].forEach((invalidInput) => {
const fi = new FakeInput();
const rli = new readline.Interface({
input: fi,
output: fi,
escapeCodeTimeout: invalidInput
});
assert.strictEqual(rli.escapeCodeTimeout, ESCAPE_CODE_TIMEOUT);
rli.close();
});
cjihrig
left a comment
There was a problem hiding this comment.
Left a few comments. Mostly trying to make the diff less noisy.
doc/api/readline.md
Outdated
There was a problem hiding this comment.
The parentheses should probably go next to "ambiguous key sequence"
lib/readline.js
Outdated
There was a problem hiding this comment.
Perhaps Number.isFinite() should be used here. It's also probably better to throw, rather than silently use a different value.
lib/readline.js
Outdated
There was a problem hiding this comment.
Could you remove this new blank line.
lib/readline.js
Outdated
There was a problem hiding this comment.
escapeCodeTimeout isn't used between here and line 101. I don't think you need to create an intermediate variable for it.
lib/readline.js
Outdated
There was a problem hiding this comment.
And if you don't introduce a new intermediate variable, you don't need to rename this.
|
@raoofha if you have some time, would you be so kind and have a look at the comments? :-) |
|
@BridgeAR sorry, I will |
lib/readline.js
Outdated
There was a problem hiding this comment.
This should be moved into the added upper if statement, since it is only necessary to test to possible provided option. If non was passed through, we already know that the value is finite.
|
@BridgeAR please take a look again |
|
hi @BridgeAR wondering when this is going to merge, or is there something that I have to do first? |
|
CI: https://ci.nodejs.org/job/node-test-pull-request/16372/ @BridgeAR I believe your comments have been addressed, PTAL |
|
Ping @BridgeAR |
|
Changes LGTM but I'm not familiar with realine, hence no green mark. ping @BridgeAR. |
|
Just as note: this did not have to wait on me. I did not block anything. |
escapeCodeTimeout option in createInterface default to ESCAPE_CODE_TIMEOUT = 500 when set to a NaN or negative number or a value other than a number set back to default value
as suggested by @BridgeAR
|
Had to rebase in order to get a proper CI: https://ci.nodejs.org/job/node-test-pull-request/17910/ |
|
Resume Build: https://ci.nodejs.org/job/node-test-pull-request/17960/ |
PR-URL: #19780 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
|
Landed in c829202 |
PR-URL: #19780 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
PR-URL: #19780 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
PR-URL: #19780 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Signed-off-by: Beth Griggs <[email protected]>
500ms for application like readline-vim is very annoying. this PR allow the developer to control the timeout.
make -j4 test(UNIX), orvcbuild test(Windows) passes