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

feat : Support for multiline statements #16

Merged
merged 1 commit into from
Aug 21, 2018

Conversation

antsmartian
Copy link
Contributor

@antsmartian antsmartian commented Jul 21, 2018

Hello,

Added the supported for multiline statements :#15

I have tested locally, it works.

Thoughts please?

Note: Recoverable.js is something I had taken from node core.

src/repl.js Outdated
const result = isRecoverableError(evaluateResult.exceptionDetails.exception, line);
if (result) {
this.io.setPrefix('...');
this.io.setMultiline(true);
Copy link
Member

@devsnek devsnek Jul 21, 2018

Choose a reason for hiding this comment

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

setMultiline should handle the ... to keep the prefix consistent (see screenshot) also we have to discard the return value of onLine because it dumps undefined when a new multiline happens (see screenshot)

otherwise this looks pretty great :D

Copy link
Member

@devsnek devsnek Jul 21, 2018

Choose a reason for hiding this comment

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

something a bit more "flowing" might be to return some symbol (IO.kNeedsAnotherLine or something) from onLine to tell the IO to buffer another line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@devsnek Sure, will work on these things. I don't get your last statement though:

something a bit more "flowing" might be to return some symbol (IO.kNeedsAnotherLine or something) from onLine to tell the IO to buffer another line

@antsmartian
Copy link
Contributor Author

@devsnek : Hey.. Have updated the PR with review comments fixed. Let me know if it's all good :) I played around and seems to be working fine:

screen shot 2018-07-26 at 6 32 33 pm

src/repl.js Outdated
// lets try for recovering
const result = isRecoverableError(evaluateResult.exceptionDetails.exception, line);
if (result) {
this.io.setPrefix('...');
Copy link
Member

Choose a reason for hiding this comment

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

io should set the prefix when it receives $multiline. also the ... needs a space after.

src/repl.js Outdated
} else {
// we tried our best - throw error
// this.io.setMultiline(false);
this.io.setPrefix('>');
Copy link
Member

Choose a reason for hiding this comment

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

arrow should be reset by io when multiline ends. also the arrow needs a space after it.

@antsmartian
Copy link
Contributor Author

@devsnek Thanks, I have done those changes locally, but somehow, I missed to push it. Now I guess it should be alright.

Thanks for your time on this.

@devsnek
Copy link
Member

devsnek commented Jul 27, 2018

ping @TimothyGu

@antsmartian
Copy link
Contributor Author

Just now realized my git username was wrong in commits; so just rewritten my commit message with right user name.

src/util.js Outdated
@@ -1,6 +1,7 @@
'use strict';

const { isIdentifierStart, isIdentifierChar } = require('acorn');
const $multiLine = Symbol('IO.kNeedsAnotherLine');
Copy link
Member

@devsnek devsnek Jul 30, 2018

Choose a reason for hiding this comment

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

the symbols description should match where the symbol is mounted and under what variable name it is mounted. you should move it to io.js file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, will look into this.

Copy link
Member

@jdalton jdalton Jul 30, 2018

Choose a reason for hiding this comment

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

Shouldn't it be multiline (lower and not camel which would suggest multi line)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jdalton Yup. I have to move this around as @devsnek suggested.

@antsmartian
Copy link
Contributor Author

antsmartian commented Aug 1, 2018

Done with the Symbol changes. cc @jdalton @devsnek

Thanks for your time.

src/io.js Outdated
@@ -1,6 +1,7 @@
'use strict';

const { emitKeys, CSI, cursorTo } = require('./tty');
const multiline = Symbol('IO.kNeedsAnotherLine');
Copy link
Member

Choose a reason for hiding this comment

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

please name the variable kNeedsAnotherLine, and if it is supposed to be IO.kNeedsAnotherLine, put it on the IO object. (IO.kNeedsAnotherLine = Symbol('IO.kNeedsAnotherLine')

@antsmartian
Copy link
Contributor Author

@devsnek Taken care, thanks. Let me know if anything needed from my side.

@antsmartian
Copy link
Contributor Author

@devsnek Any update on this? I'm waiting for your reply :)

@devsnek devsnek merged commit 2ac4bcd into nodejs:master Aug 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants