Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC]: add support for whole command insertion when pressing up/down in the REPL #2070

Open
3 tasks done
kgryte opened this issue Mar 27, 2024 · 6 comments · May be fixed by #2531
Open
3 tasks done

[RFC]: add support for whole command insertion when pressing up/down in the REPL #2070

kgryte opened this issue Mar 27, 2024 · 6 comments · May be fixed by #2531
Assignees
Labels
difficulty: 3 Likely to be challenging but manageable. Enhancement Issue or pull request for enhancing existing functionality. JavaScript Issue involves or relates to JavaScript. Needs Discussion Needs further discussion. priority: Normal Normal priority concern or feature request. REPL Issue or pull request specific to the project REPL. RFC Request for comments. Feature requests and proposed changes.

Comments

@kgryte
Copy link
Member

kgryte commented Mar 27, 2024

Description

This RFC proposes changing the default behavior in the REPL such that, when hitting the up/down arrow, an entire command is inserted, rather than just a line.

Currently, if you enter multi-line input

In [1]: function foo() {
    // ...
};

In [2]: <|>

and hit the up arrow, you get

In [2]:    };

This may be useful, but it is likely not what you want. Instead, you'd probably prefer to cycle through the entire command. In which case, when we press the UP arrow, we'd like to re-enter multi-line mode with the entirety of the previous command.

Note that currently we rely on built-in readline/REPL history behavior. In order to support this feature, we may need to maintain our own history record and capture key presses in order to efficiently cycle through entire previous commands.

Related Issues

Questions

  • Should this be configurable?
  • Should we support a mode (e.g., via a modifier key) to allow single-line insertion, as currently supported?

Other

No.

Checklist

  • I have read and understood the Code of Conduct.
  • Searched for existing issues and pull requests.
  • The issue name begins with RFC:.
@kgryte kgryte added Enhancement Issue or pull request for enhancing existing functionality. RFC Request for comments. Feature requests and proposed changes. Needs Discussion Needs further discussion. difficulty: 3 Likely to be challenging but manageable. REPL Issue or pull request specific to the project REPL. priority: Normal Normal priority concern or feature request. JavaScript Issue involves or relates to JavaScript. labels Mar 27, 2024
@Snehil-Shah
Copy link
Member

Should we allow cycling through failed commands? I think yes as the user can quickly bring it up and fix/edit it further (?)

@Snehil-Shah Snehil-Shah self-assigned this Jul 4, 2024
@kgryte
Copy link
Member Author

kgryte commented Jul 4, 2024

Yes, I think that makes sense.

@Snehil-Shah
Copy link
Member

In other REPLs and in built-in readline, this feature only works when hitting the up arrow when the cursor is at the start of the command. In IPython, I think they have the ability to filter as well. Say I type he and now I hit up arrow, commands only starting with he comes up. Something like this is proposed in #2069.

@kgryte
Copy link
Member Author

kgryte commented Jul 4, 2024

I think it only working when cursor is at the start of the line makes sense. I believe this is the same behavior as in the terminal.

For filtering, yeah, this should be reserved for reverse search.

@Snehil-Shah
Copy link
Member

Wait, I think built-in readline also does it similar to IPython. h<|> and pressing the up arrow would bring up history starting with h. Should I stick with this?

@kgryte
Copy link
Member Author

kgryte commented Jul 5, 2024

Seems okay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: 3 Likely to be challenging but manageable. Enhancement Issue or pull request for enhancing existing functionality. JavaScript Issue involves or relates to JavaScript. Needs Discussion Needs further discussion. priority: Normal Normal priority concern or feature request. REPL Issue or pull request specific to the project REPL. RFC Request for comments. Feature requests and proposed changes.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants