Skip to content
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: Adding code for handling multiline history #22153

Closed
wants to merge 1 commit into from

Conversation

antsmartian
Copy link
Contributor

@antsmartian antsmartian commented Aug 6, 2018

I always wanted to handle multiline history separately. For example, if I enter a multiline statement and then navigate between the history(s), its very annoying as it shows each line, but I expect it to show the executed line.

This is work in progress, but yeah its working and all test cases are passing. I need to handle few more cases and write a unit test case. But thought, what others think over this? May be there is also a better way to do it.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added readline Issues and PRs related to the built-in readline module. repl Issues and PRs related to the REPL subsystem. labels Aug 6, 2018
@antsmartian
Copy link
Contributor Author

Ok looks interesting, test on my mac works perfectly fine. Not sure why CI build is failing though 😕

@maclover7
Copy link
Contributor

cc @nodejs/repl

@BridgeAR
Copy link
Member

BridgeAR commented Sep 5, 2018

It would be great to get multi line support in the repl. I guess the approach itself is fine for as a first start.

Looping in @jdalton. You seemed to have interest in the repl as well.

@antsmartian
Copy link
Contributor Author

@BridgeAR Thanks for taking a look at it (Yes, I'm interested in repl too 😃 ). Lets wait for @jdalton comments. Ofcourse, this will be in progress as I have to add few more code and as well as test cases for the same.

lib/readline.js Outdated
@@ -216,6 +217,7 @@ function Interface(input, output, completer, terminal) {

this.history = [];
this.historyIndex = -1;
console.log('Yes initialized....\n\n\n', this.history);
Copy link
Member

Choose a reason for hiding this comment

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

☝️ is that debug?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My bad, yes did for debugging. Will remove them and update the PR with test cases :)

@antsmartian
Copy link
Contributor Author

@jdalton Have removed the console statement also added the test. Can you please have a look at it?

@antsmartian
Copy link
Contributor Author

@jdalton Can you kindly loop in other folks who also needs to approve this PR before it will get merged? Thanks!

@jdalton
Copy link
Member

jdalton commented Oct 4, 2018

Friendly re-ping of @nodejs/repl 🔊

{ // Tests multiline history
env: {},
test: ['{', '}', UP, CLEAR],
expected: [prompt, '{', '... ', '}', '{}\n', prompt, `${prompt}{}`, prompt], // eslint-disable-line max-len
Copy link
Member

Choose a reason for hiding this comment

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

nit: this really shouldn't need the exclusion... just go ahead and wrap.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jasnell Sure, will take care and push the change. Thanks!

@antsmartian
Copy link
Contributor Author

antsmartian commented Oct 11, 2018

@jasnell : Addressed your review comments.

@antsmartian
Copy link
Contributor Author

@jasnell / @jdalton Anything needed from my side? Or else can we merge them? Let me know.

@jasnell
Copy link
Member

jasnell commented Oct 14, 2018

There shouldn't be anything else. A lot of us have been tied up this week with a conference. Hopefully this will be landed here soon

@lundibundi
Copy link
Member

@lundibundi lundibundi added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Oct 26, 2018
@lundibundi
Copy link
Member

Friendly ping @nodejs/repl if anyone wants to take another look as quite some time has passed.

@antsmartian
Copy link
Contributor Author

@jasnell / @jdalton : Friendly ping 🔔

lib/repl.js Outdated Show resolved Hide resolved
@jdalton
Copy link
Member

jdalton commented Nov 2, 2018

This looks more like a bug fix to me.

Trott pushed a commit to Trott/io.js that referenced this pull request Nov 2, 2018
PR-URL: nodejs#22153
Reviewed-By: John-David Dalton <john.david.dalton@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@Trott
Copy link
Member

Trott commented Nov 2, 2018

Landed in dd7a3d2

@Trott Trott closed this Nov 2, 2018
@antsmartian
Copy link
Contributor Author

Thanks everyone!

@antsmartian antsmartian deleted the multiline-history branch November 3, 2018 10:25
@antsmartian antsmartian restored the multiline-history branch November 3, 2018 10:25
@antsmartian antsmartian deleted the multiline-history branch November 3, 2018 10:26
@antsmartian antsmartian restored the multiline-history branch November 3, 2018 10:26
targos pushed a commit that referenced this pull request Nov 3, 2018
PR-URL: #22153
Reviewed-By: John-David Dalton <john.david.dalton@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@antsmartian
Copy link
Contributor Author

@targos I think this can be backported to 10.x. What do you think? I would be happy to raise a PR for the same.

@targos
Copy link
Member

targos commented Nov 20, 2018

If this is backported to v10.x, it should be done with #24389

@antsmartian
Copy link
Contributor Author

I guess we are good here, I couldn't see the code in 10.x stage : https://github.com/nodejs/node/blob/v0.10-staging/lib/readline.js

@MylesBorins MylesBorins added semver-minor PRs that contain new features and should be released in the next minor version. dont-land-on-v8.x labels Nov 27, 2018
@MylesBorins
Copy link
Member

This seems like it should perhaps have been Semver-Minor... is that a correct assumption?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. readline Issues and PRs related to the built-in readline module. repl Issues and PRs related to the REPL subsystem. semver-minor PRs that contain new features and should be released in the next minor version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet