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 custom key bindings in the REPL #2647

Open
3 tasks done
Snehil-Shah opened this issue Jul 22, 2024 · 6 comments · May be fixed by #2739
Open
3 tasks done

[RFC]: add support for custom key bindings in the REPL #2647

Snehil-Shah opened this issue Jul 22, 2024 · 6 comments · May be fixed by #2739
Labels
difficulty: 4 Likely to be moderately difficult. 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

@Snehil-Shah
Copy link
Member

Snehil-Shah commented Jul 22, 2024

Description

This RFC proposes adding support for custom key bindings in the REPL.

Some prior art:

  • Julia: supports key bindings for actions like editing, cursor movement, and program control. Here's the full list of actions

  • IPython: They also support multiple key bindings for a single action. Similar to how we have the right arrow and TAB to auto-complete a suggestion. They also have auto-closing pairs as "key bindings", to trigger the 'auto-close-parentheses' is mapped to the key (. Here's the full list of actions

We would also want to support having custom key bindings for current actions like Ctrl+O for inserting a new line, or right arrow for accepting a suggestion, or the TAB key to toggle the completions etc.

Would suggest reading the above lists of actions for further discussion on what we should support

Checklist

  • I have read and understood the Code of Conduct.
  • Searched for existing issues and pull requests.
  • The issue name begins with RFC:.
@Snehil-Shah Snehil-Shah added Enhancement Issue or pull request for enhancing existing functionality. RFC Request for comments. Feature requests and proposed changes. REPL Issue or pull request specific to the project REPL. labels Jul 22, 2024
@kgryte
Copy link
Member

kgryte commented Jul 22, 2024

Most of Julia's keybindings seem reasonable. IPython's are a little hard to follow; however, some of the autosuggestion bindings could be useful.

@kgryte kgryte added Needs Discussion Needs further discussion. priority: Normal Normal priority concern or feature request. JavaScript Issue involves or relates to JavaScript. difficulty: 4 Likely to be moderately difficult. labels Jul 22, 2024
@Snehil-Shah
Copy link
Member Author

Should we allow multiple keybindings for an action?

@kgryte
Copy link
Member

kgryte commented Jul 26, 2024

Seems fine to me.

@Snehil-Shah
Copy link
Member Author

Snehil-Shah commented Aug 1, 2024

Should we allow configuring basic actions like backspace and moving left/right (using arrow keys) which are implemented by readline? We would have to override the default readline behavior to make it configurable.

Update: Let's just make it configurable, instead of reimplementing the behavior, we can just "pipe" the new key binding to call the old key binding sequence.

@kgryte
Copy link
Member

kgryte commented Aug 1, 2024

Whatever you think makes sense. My initial thought was that supporting overriding for those keybindings seems like a rabbit hole if it means overriding readline, but if you think you have a reasonable workaround, seems fine to me.

@Snehil-Shah
Copy link
Member Author

Should I break it into separate PRs, namely:

  • adding editor actions and keybinding support
  • updating current actions to be configurable
  • add settings and updating docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: 4 Likely to be moderately difficult. 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