Uh oh!
There was an error while loading. Please reload this page.
readline: add paste bracket mode - fixes #45213 - #47150
Merged
Merged
Conversation
ContributorAuthor
I was testing this code with something like this, this is a basic test: constreadline=require('readline');letcmd='';constrl=readline.createInterface({input: process.stdin,output: process.stdout});// add the paste bracket markers to output codeprocess.stdin.on('keypress',(c,k)=>{if(k?.name?.match(/^paste-/)){cmd+=k.sequence;}});// enable paste bracket modeprocess.stdout.write('\x1b[?2004h');rl.on('line',function(line){cmd+=line;// we clear old paste brackets that we don't need anymoreif(cmd.match(/\x1b\[201~$/)){cmd=cmd.replace(/\x1b\[(200|201)~/g,'');}cmd+='\n';// get rid of the opening paste bracketconstcode=cmd.replace(/\x1b\[200~/g,'');// first you check if this is multiline if the code ends// my case is lisp code it's easy to check// if there are balanced parenthesesif(/* multi-line */){if(cmd.match(/\x1b\[200~/)){// do indentation when copy-pasting the code// you can check if the code is indented or not}else{// user pressed enter so you can use normal auto-indent}}else{// evaluate the code}});in the base case when you want to indent the next line you check if cmd has paste brackets code and you evaluate the code variable. |
bnoordhuis
approved these changes
Apr 14, 2023
ContributorAuthor
What's now? When this will be merged? It's been two months since this issue was approved. |
jcubic
commented
Jul 6, 2023
ContributorAuthor
@bnoordhuis what is the status? |
bnoordhuis
commented
Jul 7, 2023
Member
@nodejs/repl - review requested |
cola119
approved these changes
Jul 12, 2023
nodejs-github-bot
commented
Jul 16, 2023
Collaborator
jcubic
commented
Jul 16, 2023
ContributorAuthor
Will check the test when I get back home. Any clue why tests failed on Linux? |
This was referenced Jul 17, 2023
nodejs-github-bot
commented
Jul 30, 2023
Collaborator
This was referenced Aug 1, 2023
nodejs-github-bot
commented
Aug 10, 2023
Collaborator
nodejs-github-bot
commented
Aug 10, 2023
Collaborator
29 tasks
nodejs-github-bot
commented
Aug 11, 2023
Collaborator
nodejs-github-bot
commented
Aug 12, 2023
Collaborator
The paste bracket mode allows REPL to have auto-indentation that is handled differently when the user copy-pastes the code from the clipboard and the code already has an indentation. PR-URL: nodejs#47150Fixes: nodejs#45213 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Kohei Ueno <kohei.ueno119@gmail.com>
aduh95
commented
Aug 12, 2023
Contributor
Landed in 87af913 |
This was referenced Aug 13, 2023
Ceres6 pushed a commit
to Ceres6/node
that referenced
this pull request
Aug 14, 2023
The paste bracket mode allows REPL to have auto-indentation that is handled differently when the user copy-pastes the code from the clipboard and the code already has an indentation. PR-URL: nodejs#47150Fixes: nodejs#45213 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Kohei Ueno <kohei.ueno119@gmail.com>
Ceres6 pushed a commit
to Ceres6/node
that referenced
this pull request
Aug 14, 2023
The paste bracket mode allows REPL to have auto-indentation that is handled differently when the user copy-pastes the code from the clipboard and the code already has an indentation. PR-URL: nodejs#47150Fixes: nodejs#45213 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Kohei Ueno <kohei.ueno119@gmail.com>
RafaelGSS pushed a commit
that referenced
this pull request
Aug 15, 2023
The paste bracket mode allows REPL to have auto-indentation that is handled differently when the user copy-pastes the code from the clipboard and the code already has an indentation. PR-URL: #47150Fixes: #45213 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Kohei Ueno <kohei.ueno119@gmail.com>
Merged
RafaelGSS pushed a commit
to RafaelGSS/node
that referenced
this pull request
Aug 15, 2023
The paste bracket mode allows REPL to have auto-indentation that is handled differently when the user copy-pastes the code from the clipboard and the code already has an indentation. PR-URL: nodejs#47150Fixes: nodejs#45213 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Kohei Ueno <kohei.ueno119@gmail.com>
RafaelGSS pushed a commit
that referenced
this pull request
Aug 16, 2023
The paste bracket mode allows REPL to have auto-indentation that is handled differently when the user copy-pastes the code from the clipboard and the code already has an indentation. PR-URL: #47150Fixes: #45213 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Kohei Ueno <kohei.ueno119@gmail.com>
RafaelGSS pushed a commit
that referenced
this pull request
Aug 17, 2023
The paste bracket mode allows REPL to have auto-indentation that is handled differently when the user copy-pastes the code from the clipboard and the code already has an indentation. PR-URL: #47150Fixes: #45213 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Kohei Ueno <kohei.ueno119@gmail.com>
targos pushed a commit
that referenced
this pull request
Nov 27, 2023
The paste bracket mode allows REPL to have auto-indentation that is handled differently when the user copy-pastes the code from the clipboard and the code already has an indentation. PR-URL: #47150Fixes: #45213 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Kohei Ueno <kohei.ueno119@gmail.com>
sercher added a commit
to sercher/graaljs
that referenced
this pull request
Apr 25, 2024
The paste bracket mode allows REPL to have auto-indentation that is handled differently when the user copy-pastes the code from the clipboard and the code already has an indentation. PR-URL: nodejs/node#47150Fixes: nodejs/node#45213 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Kohei Ueno <kohei.ueno119@gmail.com>
sercher added a commit
to sercher/graaljs
that referenced
this pull request
Apr 25, 2024
The paste bracket mode allows REPL to have auto-indentation that is handled differently when the user copy-pastes the code from the clipboard and the code already has an indentation. PR-URL: nodejs/node#47150Fixes: nodejs/node#45213 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Kohei Ueno <kohei.ueno119@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The paste bracket mode allows REPL to have auto-indentation that is handled differently when the user copy-pastes the code from the clipboard and the code already has an indentation.
There are no unit tests because there is no way to test copy-pate. You will need to have the equivalent of Cypress or Playwright for Terminal to test (but I'm also not sure if you can easily test copy-paste in those front-end frameworks).
Fixes: #45213