Skip to content

[RFC]: add support for bracketed paste in the REPL #2068

Closed

Description

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

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

Checklist

  • I have read and understood the Code of Conduct.
  • Searched for existing issues and pull requests.
  • The issue name begins with RFC:.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    EnhancementIssue or pull request for enhancing existing functionality.JavaScriptIssue involves or relates to JavaScript.Needs DiscussionNeeds further discussion.REPLIssue or pull request specific to the project REPL.RFCRequest for comments. Feature requests and proposed changes.difficulty: 3Likely to be challenging but manageable.priority: NormalNormal priority concern or feature request.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions