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

feat: Add assignment and pipe keybindings #142

Merged
merged 2 commits into from
Jun 26, 2024
Merged

feat: Add assignment and pipe keybindings #142

merged 2 commits into from
Jun 26, 2024

Conversation

gadenbuie
Copy link
Contributor

@gadenbuie gadenbuie commented Jun 13, 2024

This PR adds two common and highly popular keybindings to the editor for the R app engine:

  • Alt/Opt + -: Assignment operator <-
  • Ctrl/Cmd + Shift + M: Pipe operator |>

Given that r-wasm works with R >= 4.3, I think it's fair to use the base-R pipe operator and not worth the additional effort required to make the keybinding configurable.

The keybindings take care to only add a leading and trailing space when there isn't already space around the current cursor position.

Kapture.2024-06-13.at.17.00.03.mp4

@gadenbuie gadenbuie requested a review from wch June 13, 2024 21:02
@wch
Copy link
Collaborator

wch commented Jun 14, 2024

Looks good overall!

A couple of issues I noticed:

  • If text is selected and you use one of these shortcuts, the selected text is not replaced. Instead, the selection becomes unselected, and then the text is inserted at the cursor location.
  • If there are multiple cursors, then using these shortcuts only inserts the text at the first cursor, and also makes all the other cursors disappear.

@gadenbuie
Copy link
Contributor Author

  • If text is selected and you use one of these shortcuts, the selected text is not replaced. Instead, the selection becomes unselected, and then the text is inserted at the cursor location.

I was okay with this, but I don't have strong feelings either way. This is how insertion works in vscode with vscode-R, so I'm pretty used to it now, but in RStudio the selection is replaced.

@gadenbuie
Copy link
Contributor Author

gadenbuie commented Jun 14, 2024

@wch Okay, I've fixed both of the issues you pointed out. The keybinding now replaces the current selection and supports multicursor insertion. It also works out correct whitespace for each cursor.

Kapture.2024-06-14.at.16.20.08.mp4

Copy link
Collaborator

@schloerke schloerke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the video!

@wch wch merged commit 4b6b50b into main Jun 26, 2024
2 checks passed
@wch wch deleted the feat/r-shortcuts branch June 26, 2024 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants