Skip to content

repl: support syntax highlighting#53571

Closed
avivkeller wants to merge 1 commit into
nodejs:mainfrom
avivkeller:repl-syntax-highlighting
Closed

repl: support syntax highlighting#53571
avivkeller wants to merge 1 commit into
nodejs:mainfrom
avivkeller:repl-syntax-highlighting

Conversation

@avivkeller

@avivkeller avivkeller commented Jun 24, 2024

Copy link
Copy Markdown
Member

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 🎉

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."

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. repl Issues and PRs related to the REPL subsystem. labels Jun 24, 2024
@avivkeller avivkeller changed the title repl: enable syntax highlighting repl: support syntax highlighting Jun 24, 2024
@avivkeller

Copy link
Copy Markdown
Member Author

CC @nodejs/repl

@avivkeller avivkeller mentioned this pull request Jun 24, 2024
3 tasks
@ZYSzys

ZYSzys commented Jun 25, 2024

Copy link
Copy Markdown
Member

Could you add some tests ?

@avivkeller

avivkeller commented Jul 2, 2024

Copy link
Copy Markdown
Member Author

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

The failed tests appear unrelated.

@avivkeller avivkeller added the review wanted PRs that need reviews. label Jul 9, 2024
Comment thread test/parallel/test-repl-syntax-highlighting.js Outdated
Comment thread lib/repl.js
Comment thread lib/internal/repl/highlight.js Outdated
@avivkeller avivkeller removed the review wanted PRs that need reviews. label Jul 10, 2024
@avivkeller

Copy link
Copy Markdown
Member Author

(got review - removing label)

@avivkeller avivkeller requested a review from atlowChemi July 10, 2024 21:13
@avivkeller

Copy link
Copy Markdown
Member Author

@atlowChemi

All review conversations have been resolved, any more notes?

@BridgeAR

Copy link
Copy Markdown
Member

@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 :)

@avivkeller

avivkeller commented Jul 11, 2024

Copy link
Copy Markdown
Member Author

@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

@MoLow

MoLow commented Jul 14, 2024

Copy link
Copy Markdown
Member

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

I think both :)

@avivkeller avivkeller added semver-minor PRs that contain new features and should be released in the next minor version. notable-change PRs with changes that should be highlighted in changelogs. labels Jul 14, 2024
@github-actions

Copy link
Copy Markdown
Contributor

The notable-change PRs with changes that should be highlighted in changelogs. 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.

@avivkeller

avivkeller commented Jul 14, 2024

Copy link
Copy Markdown
Member Author

@MoLow ive added both labels.

@avivkeller

Copy link
Copy Markdown
Member Author

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 :-)!

@atlowChemi atlowChemi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

@avivkeller

avivkeller commented Jul 16, 2024

Copy link
Copy Markdown
Member Author

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.

@atlowChemi

Copy link
Copy Markdown
Member

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

@avivkeller avivkeller requested a review from atlowChemi July 17, 2024 16:00
@atlowChemi atlowChemi added the request-ci Add this label to start a Jenkins CI on a PR. label Aug 7, 2024
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 7, 2024
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@atlowChemi atlowChemi added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Aug 7, 2024
@avivkeller avivkeller added the commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. label Aug 7, 2024
@avivkeller

avivkeller commented Aug 7, 2024

Copy link
Copy Markdown
Member Author

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 avivkeller added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. and removed author ready PRs that have at least one approval, no pending requests for changes, and a CI started. labels Aug 7, 2024
@avivkeller

Copy link
Copy Markdown
Member Author

Fixed the issue, readded the label.

@avivkeller avivkeller removed the commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. label Aug 8, 2024
@jasnell jasnell added the request-ci Add this label to start a Jenkins CI on a PR. label Aug 11, 2024
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 11, 2024
@nodejs-github-bot

This comment was marked as outdated.

@avivkeller

Copy link
Copy Markdown
Member Author

The failed CI is unrelated.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@avivkeller

Copy link
Copy Markdown
Member Author

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?

input: " { b: 1 }['b'] === 1",
preview: [
" { b: 1 }['b'] === 1\r",
"\x1B[1G\x1B[0Jrepl > \x1B[9G\x1B[1G\x1B[0Jrepl > {\x1B[10G\x1B[1G\x1B[0Jrepl > { \x1B[11G\x1B[1G\x1B[0Jrepl > { b\x1B[12G\x1B[1G\x1B[0Jrepl > { b\x1B[36m:\x1B[39m\x1B[12G\x1B[1G\x1B[0Jrepl > { b\x1B[36m:\x1B[39m \x1B[13G\x1B[1G\x1B[0Jrepl > { b\x1B[36m:\x1B[39m \x1B[33m1\x1B[39m\x1B[12G\x1B[1G\x1B[0Jrepl > { b\x1B[36m:\x1B[39m \x1B[33m1\x1B[39m \x1B[12G\x1B[1G\x1B[0Jrepl > { b\x1B[36m:\x1B[39m \x1B[33m1\x1B[39m }\x1B[12G\x1B[1G\x1B[0Jrepl > { b\x1B[36m:\x1B[39m \x1B[33m1\x1B[39m }[\x1B[13G\x1B[1G\x1B[0Jrepl > { b\x1B[36m:\x1B[39m \x1B[33m1\x1B[39m }[\x1B[32m'\x1B[39m\x1B[13G\x1B[1G\x1B[0Jrepl > { b\x1B[36m:\x1B[39m \x1B[33m1\x1B[39m }[\x1B[32m'b\x1B[39m\x1B[14G\x1B[1G\x1B[0Jrepl > { b\x1B[36m:\x1B[39m \x1B[33m1\x1B[39m }[\x1B[32m'b'\x1B[39m\x1B[13G\x1B[1G\x1B[0Jrepl > { b\x1B[36m:\x1B[39m \x1B[33m1\x1B[39m }[\x1B[32m'b'\x1B[39m]\x1B[13G\x1B[1G\x1B[0Jrepl > { b\x1B[36m:\x1B[39m \x1B[33m1\x1B[39m }[\x1B[32m'b'\x1B[39m] \x1B[13G\x1B[1G\x1B[0Jrepl > { b\x1B[36m:\x1B[39m \x1B[33m1\x1B[39m }[\x1B[32m'b'\x1B[39m] \x1B[36m=\x1B[39m\x1B[14G\x1B[1G\x1B[0Jrepl > { b\x1B[36m:\x1B[39m \x1B[33m1\x1B[39m }[\x1B[32m'b'\x1B[39m] \x1B[36m==\x1B[39m\x1B[14G\x1B[1G\x1B[0Jrepl > { b\x1B[36m:\x1B[39m \x1B[33m1\x1B[39m }[\x1B[32m'b'\x1B[39m] \x1B[36m===\x1B[39m\x1B[15G\x1B[1G\x1B[0Jrepl > { b\x1B[36m:\x1B[39m \x1B[33m1\x1B[39m }[\x1B[32m'b'\x1B[39m] \x1B[36m===\x1B[39m \x1B[14G\x1B[1G\x1B[0Jrepl > { b\x1B[36m:\x1B[39m \x1B[33m1\x1B[39m }[\x1B[32m'b'\x1B[39m] \x1B[36m===\x1B[39m \x1B[33m1\x1B[39m\x1B[14G\r",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Example

@avivkeller

Copy link
Copy Markdown
Member Author

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

@avivkeller avivkeller closed this Sep 21, 2024
@atlowChemi

Copy link
Copy Markdown
Member

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

@avivkeller avivkeller reopened this Sep 21, 2024
@avivkeller

Copy link
Copy Markdown
Member Author

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

@aduh95 aduh95 added semver-major PRs that contain breaking changes and should be released in the next major version. and removed semver-minor PRs that contain new features and should be released in the next minor version. author ready PRs that have at least one approval, no pending requests for changes, and a CI started. labels Sep 24, 2024
@avivkeller

Copy link
Copy Markdown
Member Author

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 avivkeller closed this Oct 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ci PRs that need a full CI run. notable-change PRs with changes that should be highlighted in changelogs. repl Issues and PRs related to the REPL subsystem. semver-major PRs that contain breaking changes and should be released in the next major version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants