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

Paredit allows typing of closing, unbalanced parenthesis #1075

Closed
javahippie opened this issue Mar 21, 2021 · 5 comments
Closed

Paredit allows typing of closing, unbalanced parenthesis #1075

javahippie opened this issue Mar 21, 2021 · 5 comments
Labels
highlight Syntax highlighting, rainbow parens, such things paredit Paredit and structural editing

Comments

@javahippie
Copy link

Thank you very much for this project, I recently switched from Emacs and I am loving it so far!

I realized, that with Calva I am allowed to type ], ) or } in the editor. I am a little clumsy while typing, so it happens quite often to me. This produces an unbalanced parenthesis, which is immediately marked as an error. In the editor, I am not allowed to delete it with backspace, although ALT+Backspace works.

The default mode in Emacs' paredit prevented me from typing these characters entirely. which makes sense to me, as there should be no reason to create unbalanced parens in Clojure at all.

Is this something it does on purpose? If so, would it be possible to create a setting to change this behavior?

@PEZ
Copy link
Collaborator

PEZ commented Mar 21, 2021

Hello. Happy to hear you are enjoying Calva!

It is not on purpose. Just never dealt with.

@PEZ PEZ added highlight Syntax highlighting, rainbow parens, such things paredit Paredit and structural editing labels Mar 21, 2021
@PEZ PEZ mentioned this issue Apr 3, 2021
16 tasks
@PEZ
Copy link
Collaborator

PEZ commented Apr 4, 2021

Just realized that this is a duplicate of #650 .

But let's keep this open anyway.

So far I can report that this is not as easy to fix as I first thought it would be. VS Code doesn't really provide a way to catch input before it has updated the document. And just removing the brackets after the fact sometime conflicts with VS Code settings for preventing extraneous closing brackets... Right now I am experimenting with deleting the bracket, then figuring out if it should be re-inserted. We'll see where that lands me. 😄

@PEZ
Copy link
Collaborator

PEZ commented Apr 4, 2021

It doesn't seem to be possible to fix this properly. I've chosen to add a setting where the user can opt in on having some protection against it. See #1099 for details.

Here's a VSIX with this implemented: https://12588-125431277-gh.circle-artifacts.com/0/tmp/artifacts/calva-2.0.185-1098-paredit-quality-9eaa60a3.vsix

Please give it a spin and let me know if it works or causes trouble of any kind.

@javahippie
Copy link
Author

Thank you very much, I really appreciate your time spent on this!

With the setting enabled, it looks good to me, works as expected for me 👍 Even better, as unmatched parens can be easily fixed that way (e.g. after copying an incomplete form on accident.

Also with the setting disabled, it seems like I no longer need to force delete unmatched parens, right?

No troubles caused until now, thanks again!

@PEZ
Copy link
Collaborator

PEZ commented Apr 5, 2021

Thanks for testing it so swiftly!

Yes, as part of this fix we now do not offer bracket protection in unbalanced documents. Since unbalance throws Paredit out of whack we can't offer any accurate protection anyway. Note that in this state you can remove any bracket, not just the unmatched one, but hopefully the highlighting of the offending bracket should help in targeting the right one.

I think I might have found a way to deal with the situation when there is a selection, which would allow us to enable this by default, but we'll run like this first and see what people think about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
highlight Syntax highlighting, rainbow parens, such things paredit Paredit and structural editing
Projects
None yet
Development

No branches or pull requests

2 participants