-
-
Notifications
You must be signed in to change notification settings - Fork 595
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
feat: add support for auto-closing brackets/quotations in the REPL #1680
Conversation
Signed-off-by: Snehil Shah <130062020+Snehil-Shah@users.noreply.github.com>
Signed-off-by: Snehil Shah <130062020+Snehil-Shah@users.noreply.github.com>
@kgryte maybe we can also add a keyboard shortcut to toggle this behaviour? |
@Snehil-Shah Atm, we don't have any support for keyboard shortcuts in the REPL, so I'd like to avoid adding anything like that here. Adding keyboard shortcuts is a future concern, but needs to be addressed more holistically (e.g., |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some initial comments.
Signed-off-by: Snehil Shah <130062020+Snehil-Shah@users.noreply.github.com>
Signed-off-by: Snehil Shah <130062020+Snehil-Shah@users.noreply.github.com>
Signed-off-by: Snehil Shah <130062020+Snehil-Shah@users.noreply.github.com>
Signed-off-by: Snehil Shah <130062020+Snehil-Shah@users.noreply.github.com>
Signed-off-by: Snehil Shah <130062020+Snehil-Shah@users.noreply.github.com>
@kgryte IPython uses CTRL+O to manually add multi-line, maybe we can add that too on top of ALT+ENTER? |
Hmm...CTRL+O is not obvious to me. I think people are more likely to be used to chat apps which use CMD or SHIFT as the modifier with ENTER. |
Signed-off-by: Snehil Shah <130062020+Snehil-Shah@users.noreply.github.com>
@kgryte improved the manual multi-line editing by making it cursor-aware. when manually adding a newline (using alt+enter), it adds a newline from the cursor position just like a text editor would! is this okay? |
Signed-off-by: Snehil Shah <130062020+Snehil-Shah@users.noreply.github.com>
Signed-off-by: Snehil Shah <130062020+Snehil-Shah@users.noreply.github.com>
@kgryte Made auto-closing symbols more ergonomic by handling the case where the user instinctively adds a closing bracket when typing with flow. The extra closing symbol is discarded similar to IDEs. |
@Snehil-Shah Thanks for adding auto-delete tests! |
They are certainly related, but, while often they are implemented together, IMO they are still distinct. As a user, I may want auto-deletion, but not auto-closing because I may find auto-insertion annoying or want more fine-grained control as to when characters are inserted. And vice versa. For auto-deletion in particular, if I typed |
Signed-off-by: Snehil Shah <snehilshah.989@gmail.com>
Ah, okay, that was why you had that logic in there; I wasn't able to figure out from the comments alone what the intent was. But also, the regexp approach was too limited, as string content can be more than just ASCII. I think I have a solution for this and can push up a fix later today. |
lib/node_modules/@stdlib/repl/test/integration/test.auto_close_pairs.js
Outdated
Show resolved
Hide resolved
Signed-off-by: Snehil Shah <snehilshah.989@gmail.com>
Signed-off-by: Snehil Shah <snehilshah.989@gmail.com>
@Snehil-Shah Okay. I think this is in a pretty good state. You mind doing a final review to check that we didn't miss anything? |
@kgryte Checked everything, looks good to go👍 |
@Snehil-Shah Thanks for checking! Let's go ahead and get this in. Any subsequent work can be addressed in follow-up PRs. Thanks for your work on this; this is really nice functionality to have. |
Resolves #1672
Description
This pull request:
Related Issues
This pull request:
Other
For Multi-line editing, I have used ALT+ENTER as the modifier key.
This might seem odd given SHIFT+ENTER is the conventional key combination to add a newline instead of executing a command, but it is done because the terminal or the readline module cannot differentiate between ENTER & SHIFT+ENTER or even CTRL+ENTER.
ALT+ENTER generates a different keypress value than the others.
Questions
I am utilizing readline module's private methods (shown in image) to mess with the input stream. Public apis like
write()
orcursorTo()
aren't working as expected.I am not entirely sure if it's okay to use these private methods, but they definitely work as desired.
UPDATE: Solved!
Checklist
@stdlib-js/reviewers