[RFC]: add support for bracketed paste in the REPL
Opened this issue · 1 comments
Description
This RFC proposes adding support for bracketed paste in the REPL. Currently, if you were to copy
console.log( 'foo' );
console.log( 'bar' );
into the REPL, you'd get
In [36]: console.log( 'foo' );
foo
console.log( 'bar' );
bar
where, if the pasted content contains a newline character, the expressions will be automatically evaluated.
The idea behind bracketed paste is to recognize pasted content so that a user can inspect and potentially edit pasted content before explicitly executing.
Enabling bracketed paste should be a matter of using escape sequences and then checking for a paste start sequence before executing content and then waiting for the paste to stop by checking for the stop sequence.
Once the REPL exits, we should disable bracketed paste.
Additionally, we should add an option which can be set during REPL instantiation (via the REPL constructor) for enabling/disabling bracketed paste, with the default behavior being enabled.
Related Issues
- Multi-line editing is a related concern and would be nice to have in order to edit pasted content: #2060
Questions
- Given that bracketed paste is global to a terminal window, do we need to test whether it is already enabled? And if so, avoid disabling on exit? Is this detection even possible?
Other
- Discussion: https://cirw.in/blog/bracketed-paste
Checklist
- I have read and understood the Code of Conduct.
- Searched for existing issues and pull requests.
- The issue name begins with
RFC:
.
Following up on this, now that the REPL supports auto-closing of paired symbols, the ability to paste expressions into the REPL is broken, as auto-closing attempts to automatically insert paired symbols as the expression's character sequence is written to the output stream.