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

When text is selected and either (, [ or { is pressed wrap selection in (), [], {} instead of replacing it. #757

Merged
merged 2 commits into from
Dec 10, 2020

Conversation

pankgeorg
Copy link
Collaborator

This PR adds key bindings to codemirror in order to handle the press of (, [ or { more intuitively (citation needed).

When user has done a text selection and presses (, [ or {, the character replaces the text.

With this PR, the behaviour changes to wrap the selection in brackets.

Note that the cursor is moved after the text (selected-text)<HERE> vs for example VSCode that goes to (selected-text<HERE>).

Also remove the line that activates ''autoCloseBrackets" (because it doesn't!)

@fonsp fonsp merged commit 9b4c393 into fonsp:master Dec 10, 2020
@yuhan0
Copy link

yuhan0 commented Dec 15, 2020

Hi, I looked into this a few days ago too, and found that uncommenting this line

<!-- <script src="https://cdn.jsdelivr.net/npm/codemirror@5.58.1/addon/edit/closebrackets.min.js" defer></script> -->

was enough to enable the feature of wrapping selected text in brackets, along with auto closing brackets.

Unless there was a reason for reimplementing this feature, I think it's better to just use the native codemirror addon?

@pankgeorg
Copy link
Collaborator Author

The native codemirror addon does more things than what this implementation provides.

This just adds open/close brackets when you have a selection and click parenthesis. Does not open/close in all cases.

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.

None yet

3 participants