-
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
readline: Allow history to be disabled #6352
Conversation
@suryagh May be the file reading example should also be updated by adding |
Are you referring to modifying the Example: Read File Stream Line-by-Line to include
I would prefer not to worry about historySize = |
@suryagh Yes, I referred this example and suggested this addition. Do you think this would be unnecessary? I mean, this is almost a template code, many users could take it as a base for line by line file reading without going into details. This addition would spare them unnecessary overhead. |
Sounds fine to me. Could someone describe the use-case in a bit more detail? |
@Fishrock123 I often use |
Changing from semver-minor to semver-major. This changes behavior when |
fi = new FakeInput(); | ||
rli = new readline.Interface({ input: fi, output: fi, terminal: terminal, | ||
historySize: 0 }); | ||
assert.equal(rli.historySize, 0); |
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.
Please change this to assert.strictEqual()
.
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.
👍 Done.
Can you add |
So now it can't be fixed untill Node 7.0, i.e. untill October 2016? |
It could still potentially make it into v6. |
It would be nice to include a test that verifies that items are not being included in the history. |
Could anybody help if @suryagh could not implement all the requests untill v6 deadline? |
@vsemozhetbyt when is the v6 deadline? |
I'll be cutting the v6.x branch tomorrow morning (likely around 9am pacific time) and will be kicking off the build sometime around 10am. Whatever lands before then should make it. I would prefer, however, to get any remaining semver-major PRs landed as soon as possible today in order to give more time for smoke and regression testing. |
LGTM @suryagh Thanks for the changes! |
@@ -300,7 +300,7 @@ the following values: | |||
treated like a TTY, and have ANSI/VT100 escape codes written to it. | |||
Defaults to checking `isTTY` on the `output` stream upon instantiation. | |||
|
|||
- `historySize` - maximum number of history lines retained. Defaults to `30`. | |||
- `historySize` - maximum number of history lines retained. To disable the history set this value to `0`. Defaults to `30`. |
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.
Can you wrap this at 80 characters.
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.
👍 Done.
CI is green. @suryagh The commit message may require a bit of cleanup, but we can do that upon landing if you prefer. Specifically:
|
LGTM, but I still think a test to show that the history is actually disabled would be nice. |
@cjihrig presently |
There is nothing wrong with something testing its own internal implementation. There are a few private methods in |
@addaleax made the suggested changes. |
fix nodejs#6336 1. The `historySize` to default to `30` only if `undefined`. 2. If `historySize` is set to 0, then disable caching the line. 3. Added unit tests. 4. Updated documentation.
@addaleax I'm not sure if I can get to @cjihrig suggestion by tomorrow morning cut off time. If not, then I will send a separate PR for the Btw - regarding the github handle, it is actually |
@suryagh PR’ed against your fork with a simple suggestion for tests. Be sure to write a small notification here if/when you update this PR so others can see that. I have to admit I’d feel silly if this doesn’t get included in v6 over a missing test, esp. when it’s a breaking change anyway, so I’m adding it to the milestone. If someone thinks that that doesn’t leave enough time for reviews from more people, they should feel free to remove it. |
Check that when setting `historySize: 0`, the `history` property of the readline interface is kept empty.
@addaleax merged the tests. Thank you. |
Thanks! @cjihrig That does the trick for you? |
LGTM. Thanks @addaleax |
One more CI: https://ci.nodejs.org/job/node-test-commit/3051/ |
I've looked at the last tests of @addaleax and now I feel terribly silly with all the my 'overhead' alarm — the key reason I mention this bug in the first place by. It seems all the history caching does not even start if the All the same this bug fix is still a thing of consistency. However it probably makes sense to add in the Sorry for all my stupidity and laziness to dig in this deeper (and for my poor English). |
@vsemozhetbyt Don’t worry about it too much. This is good for consistency, the less urgent it is the better, and you should by all means feel invited to write something up for the docs! |
@addaleax Thank you. I'm not so familiar with all the colaboration cobweb, so may be I shoud not interfere in this now in the last fragile moment. But if this PR lands without such clarification, I shall try to add a simple doc PR for it when all the new release bustle ceases. |
@vsemozhetbyt I think this PR is more or less good to go, anything else can be done later. |
Landed in 0303a25. |
1. The `historySize` to default to `30` only if `undefined`. 2. If `historySize` is set to 0, then disable caching the line. 3. Added unit tests. 4. Updated documentation. Fixes: #6336 PR-URL: #6352 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1. The `historySize` to default to `30` only if `undefined`. 2. If `historySize` is set to 0, then disable caching the line. 3. Added unit tests. 4. Updated documentation. Fixes: #6336 PR-URL: #6352 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
History caching in the `readline` io is active only for terminal interaction. Appropriate variables are initialized and relevant `_addHistory()` function is called only if exposed `terminal` option of `readline.createInterface()` is set `true` by user or internal output check. This clarification is useful to assure users there will be now wasted overhead connected with history caching if `readline` is used not for terminal interaction (e.g. for reading files line by line). Particularly this fix is helpful after #6352 landing. PR-URL: #6397 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Alexander Makarenko <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
History caching in the `readline` io is active only for terminal interaction. Appropriate variables are initialized and relevant `_addHistory()` function is called only if exposed `terminal` option of `readline.createInterface()` is set `true` by user or internal output check. This clarification is useful to assure users there will be now wasted overhead connected with history caching if `readline` is used not for terminal interaction (e.g. for reading files line by line). Particularly this fix is helpful after #6352 landing. PR-URL: #6397 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Alexander Makarenko <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
History caching in the `readline` io is active only for terminal interaction. Appropriate variables are initialized and relevant `_addHistory()` function is called only if exposed `terminal` option of `readline.createInterface()` is set `true` by user or internal output check. This clarification is useful to assure users there will be now wasted overhead connected with history caching if `readline` is used not for terminal interaction (e.g. for reading files line by line). Particularly this fix is helpful after nodejs#6352 landing. PR-URL: nodejs#6397 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Alexander Makarenko <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
Checklist
Affected core subsystem(s)
readline
Description of change
Fixes #6336
historySize
to default to30
only ifundefined
.historySize
is set to 0, then disable caching the line.