node icon indicating copy to clipboard operation
node copied to clipboard

repl: support syntax highlighting

Open avivkeller opened this issue 1 year ago • 25 comments

Instead of sending many REPL changes in one PR (#52965), it was recommended to me to implement these one-by-one in several PRs.

First up: Syntax highlighting :tada:

This PR adds RegEx-based syntax highlighting to the REPL.


Notable change text (if text this short is even worth it): "The REPL now includes syntax highlighting for input."

avivkeller avatar Jun 24 '24 15:06 avivkeller

CC @nodejs/repl

avivkeller avatar Jun 24 '24 15:06 avivkeller

Could you add some tests ?

ZYSzys avatar Jun 25 '24 06:06 ZYSzys

Tests have been added @ZYSzys, sorry I forgot to let you know when I pushed the commits.

The failed tests appear unrelated.

avivkeller avatar Jul 02 '24 16:07 avivkeller

(got review - removing label)

avivkeller avatar Jul 10 '24 20:07 avivkeller

@atlowChemi

All review conversations have been resolved, any more notes?

avivkeller avatar Jul 11 '24 12:07 avivkeller

@RedYetiDev do you have some screenshots or a short video of the usage? I am not certain in what way the syntax highlighting has changed :)

BridgeAR avatar Jul 11 '24 13:07 BridgeAR

@BridgeAR highlighting is done to input, and it follows (mostly) the same rules as util.inspect.

New

image

Old

image


I'm not sure if this is semver-minor / notable-change

avivkeller avatar Jul 11 '24 13:07 avivkeller

I'm not sure if this is semver-minor / notable-change

I think both :)

MoLow avatar Jul 14 '24 17:07 MoLow

The https://github.com/nodejs/node/labels/notable-change label has been added by @RedYetiDev.

Please suggest a text for the release notes if you'd like to include a more detailed summary, then proceed to update the PR description with the text or a link to the notable change suggested text comment. Otherwise, the commit will be placed in the Other Notable Changes section.

github-actions[bot] avatar Jul 14 '24 18:07 github-actions[bot]

@MoLow ive added both labels.

avivkeller avatar Jul 14 '24 19:07 avivkeller

All checks have passed, but I assume this needs a CI to land. If someone could review, approve, and CI, it would be appreciated. Thanks :-)!

avivkeller avatar Jul 15 '24 03:07 avivkeller

The PR currently only tests the new internal/repl/highlight module, but I think tests should be aded to ensure the input is colored in REPL as well.

The highlight function is called directly within the REPL writing, so I'm not sure how to hook into it's input writing, but I believe the tests currently in use suffice.

avivkeller avatar Jul 16 '24 19:07 avivkeller

so I'm not sure how to hook into it's output

I'd look at test like test-repl-autocomplete.js, test-repl-context.js, and test-repl-editor.js etc

atlowChemi avatar Jul 17 '24 07:07 atlowChemi

CI: https://ci.nodejs.org/job/node-test-pull-request/60923/

nodejs-github-bot avatar Aug 07 '24 06:08 nodejs-github-bot

I'm a little concerned about the failure at https://ci.nodejs.org/job/node-test-commit-linux-containered/nodes=ubuntu2204_sharedlibs_withoutssl_x64/45088/testReport/junit/(root)/parallel/test_repl_preview_without_inspector/, but it didn't seem to fail anywhere else 🤔

I've removed author ready, because I don't think this should land until that is resolved. Feel free to re add the label if you disagree.

avivkeller avatar Aug 07 '24 12:08 avivkeller

Fixed the issue, readded the label.

avivkeller avatar Aug 08 '24 22:08 avivkeller

CI: https://ci.nodejs.org/job/node-test-pull-request/61007/

nodejs-github-bot avatar Aug 11 '24 01:08 nodejs-github-bot

The failed CI is unrelated.

avivkeller avatar Aug 13 '24 16:08 avivkeller

CI: https://ci.nodejs.org/job/node-test-pull-request/61447/

nodejs-github-bot avatar Aug 25 '24 13:08 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/61448/

nodejs-github-bot avatar Aug 25 '24 14:08 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/61631/

nodejs-github-bot avatar Aug 29 '24 05:08 nodejs-github-bot

https://ci.nodejs.org/job/node-test-commit-linux-containered/45732/ is failing, and that concerns me that this API is adding to many control sequences, and it'll clutter developers trying to simply parse the output. I'm wondering if this should be closed for now, until a time where it can be implemented with less control sequencnes?

avivkeller avatar Sep 02 '24 20:09 avivkeller

I no longer think this is a good idea. See the comment above.

avivkeller avatar Sep 21 '24 15:09 avivkeller

and it'll clutter developers trying to simply parse the output

If that would be an issue, the NO_COLOR variable can be set etc, or we could add a util such as unstyleText. I don't think this is a real issue, though this might be a semver-major

atlowChemi avatar Sep 21 '24 18:09 atlowChemi

If you say so, I trust your opinion. I'll keep this open in that case, though I have my reservations.

avivkeller avatar Sep 21 '24 18:09 avivkeller

Hey y'all, I don't have the time to persue this feature, given the other Node.js-related things I am working on. I'm closing this PR, but I'm happy for someone to continue the work.

avivkeller avatar Oct 27 '24 19:10 avivkeller